ASPNET Access Connection String Question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In classic ASP I could specify a relative path (server side mapping) or
absolute path to an Access database file. I can connect to an access file
with no problems using the absolute path of "C:\Inetpub\wwwroot\db\mydb.mdb"
in ASPNET, but I'm scratching my head on how to specify a server path instead.

For example in classic ASP:
dbDriver = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
Server.MapPath("\data\inventory.mdb")

How can I specify the database connection string in ASPNET without using the
full complete path file location? Thanks in advance.
 
One option: As you build your connection string, you can use MapPath() to map
the relative path to an absolute path.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
Instead of :
dbDriver = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
Server.MapPath("\data\inventory.mdb")

use :

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\data\inventory.mdb;User
Id=admin;Password=;"

If your password is not blank, use :

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\data\inventory.mdb;Jet OLEDB:Database
Password=pwd;"



Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================
 
Juan T. Llibre said:
Instead of :


use :

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\data\inventory.mdb;User
Id=admin;Password=;"

If your password is not blank, use :

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\data\inventory.mdb;Jet OLEDB:Database
Password=pwd;"



Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================
Thank you for the help and quick replies. Your answer worked great. Thanks
again.
 
For example in classic ASP:
dbDriver = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
Server.MapPath("\data\inventory.mdb")
 
Back
Top