C # using OLE DB to manipulate access
Provider=Microsoft.Jet.OLEDB.4.0;Data source= "+ NewFileName +"; User Id=uid; Jet oledb:database password=pwd; ";
Complete 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
In Myini.dbupgrade1 () position Program.cs: line number 348
In Program.main () position Program.cs: line number 738}
cause of error:
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=""这里是你的ACCESS数据库文件的路径"+ ";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; ".
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
The System.InvalidOperationException:ConnectionString property has not been initialized.