Print Page | Close Window

Connetcing to database

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=12109
Printed Date: 30 March 2026 at 11:47pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Connetcing to database
Posted By: pieterv
Subject: Connetcing to database
Date Posted: 10 October 2004 at 8:51am

I'm having trouble to integrate Site News into my website. I cannot connect to my database as I would like. I'm using a virtual path to my database. (d:\www\websitename\database\news.mdb). WebWizNews uses a connection with server.MapPath, but i'm not familiar with that. Can anyone tell me how I can connect to my database using a virtual path.

-----------------------------------

'Create database connection

'Create a connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")
   
'------------- If you are having problems with the script then try using a diffrent driver or DSN by editing the lines below --------------
   
'Database connection info and driver
strCon = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("news.mdb")

'Database driver info for Brinkster
'strCon = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("/USERNAME/db/news.mdb") 'This one is for Brinkster users place your Brinster username where you see USERNAME

'Alternative drivers faster than the basic one above
'strCon = "Provider=Microsoft.Jet.OLEDB.3.51; Data Source=" & Server.MapPath("news.mdb") 'This one is if you convert the database to Access 97
'strCon = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("news.mdb")  'This one is for Access 2000/2002

'If you wish to use DSN then comment out the driver above and uncomment the line below (DSN is slower than the above drivers)
'strCon = "DSN = DSN_NAME" 'Place the DSN where you see DSN_NAME

---------------------------

Or can anyone tell me how I use Server.Mappath to connect to my database who is outside my webroot. (The webserver uses a database folder and a www folder)

thanks a lot.....




Replies:
Posted By: dj air
Date Posted: 12 October 2004 at 10:01am
change the red section above for this

'Database connection info and driver
strCon = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=
d:\www\websitename\database\news.mdb"

that should fix your problem.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net