C # using OLE DB to manipulate access
Provider=Microsoft.Jet.OLEDB.4.0;Data source= "+ NewFileName +"; User Id=uid; Jet oledb:database password=pwd; ";
full error message:
{The System.InvalidOperationException:ConnectionString property has not been initialized.}
In System.Data.OleDb.OleDbConnection.PermissionDemand ()
In System.Data.OleDb.OleDbConnectionFactory.PermissionDemand (DbConnection outerconnection)
In System.Data.ProviderBase.DbConnectionClosed.OpenConnection (DbConnection outerconnection, dbconnectionfactory ConnectionFactory)
In System.Data.OleDb.OleDbConnection.Open ()
In System.Data.Common.DbDataAdapter.FillInternal (DataSet DataSet, datatable[] DataTables, Int32 Startrecord, Int32 MaxRecords, String srctable, IDbCommand command, CommandBehavior behavior)
In System.Data.Common.DbDataAdapter.Fill (DataSet DataSet, Int32 Startrecord, Int32 maxrecords, String srctable, IDbCommand command, CommandBehavior behavior)
In System.Data.Common.DbDataAdapter.Fill (DataSet DataSet, String srctable)
In Public.DB.GetDataTable (String Sql) position Public\db.cs: line number 44
At Myini.dbupgrade1 () position Program.cs: line number 348
At Program.main () position Program.cs: line number 738}
Error Reason:
The ConnectionString property has not been initialized. Only the Connection object is created, and the ConnectionString property of the Connection object is not set;
Workaround:
Set the ConnectionString property of the connection object, such as the following code:
Connection.connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + "here is the path to your Access database file" + "; User Id=uid; Jet oledb:database password=pwd; ";
If the database does not have a password, you do not need to add the following "User Id=uid;" Jet oledb:database password=pwd; ".