Database Directory Error
-
I noticed a problem with this program I made. It basically just opens database files using the OleDbDataAdapter, and for some odd reason, it cannot open database files that are outside of its own directory. For example, if the project is in D:\project, and the database file is in D:\project\database.csv. It will work, but on the other hand if the database file is in C:\database.csv, it will not open it. I was wondering if anyone could help me with this. Here is my code:
oleDbConnection1.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + dir + @";Extended Properties=""text;HDR=Yes;FMT=Delimited"""; oleDbConnection1.Open(); // where the variable dir is the datasource
-
I noticed a problem with this program I made. It basically just opens database files using the OleDbDataAdapter, and for some odd reason, it cannot open database files that are outside of its own directory. For example, if the project is in D:\project, and the database file is in D:\project\database.csv. It will work, but on the other hand if the database file is in C:\database.csv, it will not open it. I was wondering if anyone could help me with this. Here is my code:
oleDbConnection1.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + dir + @";Extended Properties=""text;HDR=Yes;FMT=Delimited"""; oleDbConnection1.Open(); // where the variable dir is the datasource
The way to make this work is as follows string dir = @"C:\database.csv" or string dir = @"\\myremotepc\sharefolder\database.csv" oleDbConnection1.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + dir";Extended Properties=""text;HDR=Yes;FMT=Delimited""";
-
The way to make this work is as follows string dir = @"C:\database.csv" or string dir = @"\\myremotepc\sharefolder\database.csv" oleDbConnection1.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + dir";Extended Properties=""text;HDR=Yes;FMT=Delimited""";
Thanks for your reply, it turned out it was whitespace. I had whitespace in my connection string. That is why it was crashing. Sincerely, The Major Rager