Question

 public void SetConnection(string text1, string text2, string text3, string text4, string text5, string text6, string text7)
    {
        string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source= c:\\Users\\Clients Information pats.mdb";


        database = new OleDbConnection(connectionString);
        database.Open();

    }

data1 = DataAccess.DatabaseTables("SELECT * from [CLIENTS]", DataAccess.database);

 public DataTable DatabaseTables(string QueryString, OleDbConnection DataConnection)
    {

        OleDbCommand SQLQuery = new OleDbCommand();
        DataTable data = null;
        SQLQuery.Connection = null;
        OleDbDataAdapter dataAdapter = null;
        SQLQuery.CommandText = QueryString;
        SQLQuery.Connection = DataConnection;
        data = new DataTable();
        dataAdapter = new OleDbDataAdapter(SQLQuery);

        dataAdapter.Fill(data);
        return data;
    }

Getting a strange error as listed in the heading. Setconnection sets up my connection string and connection ok. Then 'data1' calls the function DatabaseTables which calls an exception at 'dataAdapter.Fill(data);'. I think the issue could be my access on my machine. The mdb will not open in 2013 on my machine because it is an earlier version. I installed access 2007 runtime. Opened it and it said it was read only that i need to change this attribute. Then i tried to open access 2013 as administrator, office 2013 did some reconfig by itself and now this mdb file always tries to open in access 2013. I will now try to reinstall access 2007. Is it possible i need to uninstall access 2013 or is this maybe not a access issue at all but maybe an issue with my code or the mdb itself. I copied this mdb file from a server where it opened on access 2007 on that machine but it tried to enhance it because it is apparently an even earlier version

Was it helpful?

Solution

"Provider=Microsoft.ACE.OLEDB.12.0;Data Source= u:\\Clients Information pats_30may13.accdb;Jet OLEDB:Database Password=MyDbPassword;";

I upgraded the source access database to accdb format plus made sure i could open this database on my own computer as opposed to the server. I got a notification that there were some errors with the upgrade but it appeared ok. Then i used the above connection string which solved the issue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top