Syntax issue

fkheng

Well-known member
Joined
May 8, 2003
Messages
155
Location
Malaysia
Dim conStr As String = "Provider=Microsoft.JET.OLEDB.4.0;data source=c:\\northwind.mdb"

for the data source, why does the path for c: contain a double-slash? does it mean anything?

also, is there an equivalent for App.path in VB6?
 
\ is used in strings for escape characters, ie; \n means newline. So in order to get a backslash as a regular string value, you have to use double backslash; \\

You can get around this in C# by adding @ to the beginning of your string so it treats a backslash like regular text;

@"Provider=Microsoft.JET.OLEDB.4.0;data source=c:\northwind.mdb"

So for App.Path, I believe theres an equivelent in either the Application or Environment object. I dont remember off the top of my head which one, but you can crack open the object browser and take a look.
 
A double backslash is not really necessary in this case. I never use it in my connectionstrings.
Old habits die hard :D
 
Just what it says. A single backslash is sufficient. When I connect to Acccess I allways use a single backslash for the path.
Maybe in C# its different, but in VB it works.
 
Back
Top