Access database on localhost

Himo

Regular
Joined
Dec 22, 2004
Messages
61
Location
the Netherlands
I want to access an MS access database on my localhost, but when I'm using this connection string:
String sConnString = "Driver={MS Access Driver (*.mdb)};Dbq=http://localhost/WebApplication1/bin/users.mdb;";
It just won't work, saying: Invalid filename
What could I do about it?
 
For that to work the .mdb file would be accessible to everyone from the url - not a secure option. Plus unless you are using something like WebDAV it would not be treated like a normal file anyway.
What you will need to do is get the filename at runtime via Server.MapPath(...)
e.g.
C#:
String ConnString = "Driver={MS Access Driver (*.mdb)};Dbq=" + Server.MapPath("bin/users.mdb;")
 
2 questions then:

1) WebDAV?
2) How could I configure SQL Server then correctly to do this? I couldn't figure out the hostname, since he wouldn't take 'localhost'.

Thank you very much already :)
 
http://www.webdav.org/

If you are using SQL server then you would have a totally different connection string anyway - you would not be connecting direct to a file.
However if SQL is on the same server you could get away with something like Data Source=(local) to identify the server.
 
Back
Top