How can we create a connection string to the Microsoft Access using C# programming dynamically? I tries the following code-

OleDbConnection con = new OleDbConnection();
String path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + path + "\\nik.mdb";


I got this result in response:

Format of the initialization string does not conform to specification starting at index 55.


When i edit my string it looks as below:

Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Users\nikhil\desktop\nik.mdb


Thanks in advance.


Question: MS-Access VBA Date() works on one PC but not others
Answer: Date() is controlled by the Visual Basic For Applications X.XX reference.  Make sure the reference is installed and any competing references are removed.

To do this, open the VBA window and go to Tools --> References and ensure the proper one is checked.