Reputation: 639
I have a problem that I thought someone may be able to help me with, I have a C# application that uses a Access-database. If my path is without spaces like "C:/Test/db.accdb" it works like a charm, but if the path got spaces like "C:/Test folder/db.accdb", not so much... does anyone know why this is? my code looks like this: (The query is just an example, you get the point :)
String connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + dbPath;
OleDbConnection connection = new OleDbConnection(connectionString);
OleDbCommand command;
connection.Open();
command = new OleDbCommand("UPDATE Table SET Tablevalue = 1 WHERE Tablevalue2 = 3")
command.ExecuteNonQuery();
connection.Close();
Thanks!
/Nick
Upvotes: 0
Views: 1948
Reputation: 330
Wrap the path in single quotes
String connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" + dbPath +"'"; //could use String.Format here as well.
Upvotes: 4