Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access and web pages

Status
Not open for further replies.

Ladyhawk

Programmer
Jan 22, 2002
534
AU
Does anyone use an Access database with a web page?

Ladyhawk. [idea]
** ASP/VB/Java Programmer **
 
How do you tell it where the database is without hardcoding the path?

Ladyhawk. [idea]
** ASP/VB/Java Programmer **
 
How does that work?

Ladyhawk. [idea]
** ASP/VB/Java Programmer **
 
I'll have to do this later on in the week, but look up the web.config file in the net help, and it will tell you where to put the info. It's added like: add key, or something close. You set

<appSettings>
<add key=&quot;Orders&quot;
value=&quot;server=myserver; database=mydb; user id='myuser'; password='mypwd'; integrated security=false;&quot;/>
</appSettings>

If you set this up as an ado access connection, you would have the database name and path in here as well. This is for sql server. But you get the idea.

Found this in help. I hope this helps you. :)
 
When you connect to an Access database, you usually add the path of the database. For example, database=c:\mydir\mydb.mdb.

If I am on a web server, I am not going to know c:\mydir. All I am going to know is that the database is in the same directory as the script. But how can I specify that the database is located in the same directory as the script?

Ladyhawk. [idea]
** ASP/VB/Java Programmer **
 
declare an element in your app.config to your path to the database. when the app loads, read this value and set the connection string.
 
But I don't know the exact path because I am using an ISP's web server.

Ladyhawk. [idea]
** ASP/VB/Java Programmer **
 
Use the relative path with the HttpContext.Current.Server.MapPath function (as in legacy ASP).

Ex: path = HttpContext.Current.Server.MapPath(&quot;./data/db1.mdb&quot;);
 
how do you connect to an access database in asp.net?

is it the same way as asp?

Thnx

Martin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top