Wizard
Wizard

Reputation: 11295

c# acces db file path

I'm debugging ASP application from usb flash (there is located project and I use MS Visual studio) I don't know how to indicate path to db file i try string db_adres = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=J:\test.mdb"; but this is wrong path

Upvotes: 0

Views: 187

Answers (1)

Steve
Steve

Reputation: 216363

In C# you should prefix this kind of string with the char @

string db_adres = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source='J:\test.mdb'";

or double the \ character

string db_adres = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='J:\\test.mdb'";

The first one is called 'verbatim string', the second one is an 'escaped string'
Look here at C# specifications 2.4.4.5 "String Literals"

Upvotes: 2

Related Questions