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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADODB Connection to Inventory.mdb

Status
Not open for further replies.

2122002

IS-IT--Management
Apr 22, 2003
58
US
Dear All,

I have been struglling to connect to my database (inventory.mdb) located on "Stock\Admin\inventory.mdb" direcotry.

I have two folders "Admin" and "User". I do not have problem when I run "defaul_adm.asp" under the Admin folder where the .mdb is located, however, if i tried to run "default_usr.asp" under the User folder then I have problem to execute it becuase it search for the "Inventory.mdb" database.

Below is my code, please help me:

Sub Open_Database()
set dbInvent = Server.CreateObject("ADODB.Connection")
dbInvent.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("Inventory.mdb") & ";"

End Sub


Dan
 
what is the error you are getting...make sure the folder has the correct permissions...
did you try:

Server.MapPath("./Inventory.mdb")

-DNG
 
Try:

Server.MapPath("..\Admin\Inventory.mdb")

Suggestion:
If you are going to access this DB from multiple pages in varying folders, you should create a single page (connect.asp) and put your connect string there. You would then include that file (<!--#include file="../Admin/connect.asp"-->) at the top of every page that needs to connect to the DB.
 
Think about a web site where all of the graphics are stored in an /images folder... other pages in different sub directorires will have different paths to the graphics directory... the same will be true of your .mdb file.
 
Thanx. However, it doens't work. I have check on the folder, it has read/write permission. "C:\Inetpub\ directory.

Any other method? or Any clue on using DNS?



Dan
 
Post the full code. It is probably how you call the sub. If it works when default page is in same DIR as DB, then the DB DIR has read/write so that shouldn't be a question.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top