This is a discussion on "Connecting to my Database...." within the Classic ASP section. This forum, and the thread "Connecting to my Database.... are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Connecting to my Database....
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
Connecting to my Database....
OK, I can connect to my database no problems as long as its in the WWW folder.. How do I link it to my db folder instead of my WWW???
heres what I am using now! strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("Database.mdb") |
|
|
|
#2
|
|||
|
|||
|
MapPath takes a virtual location and changes it to a absolute location. So, if your db folder is on the same level as your www folder you'd do MapPath("../db/database.mdb"), if it's in a subfolder then MapPath("db/database.mdb"). Or of course if you know the absolute location you can just put that in "...Data Source=e:\inetpub\db\database.mdb" or whatever.
The only problem with MapPath is if you use it in an include file that's called from files in different levels of directories, then the relative location of the database to the file won't be the same for them all and you'll get errors. If that doesn't make sense ignore it. |
|
#3
|
|||
|
|||
|
hrmm... Tried the virtual location thing, I have to go up 2 folders to get back to the db folder. Also, it gave me an error when I typed the ../ part. Said the .'s arent allowed. Thanks.
|
|
#4
|
|||
|
|||
|
does your host allow you to setup a DSN? if so the code just changes to:
strConnString = "DSN=<dsn-name>" |
![]() |
| Tags |
| connecting, database |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| connecting to database | franknu | PHP Forum | 4 | Jul 23rd, 2006 08:39 |
| connecting to CSV file | madhuri.t | Classic ASP | 0 | Jul 10th, 2006 13:50 |
| connecting to CSV file | madhuri.t | Classic ASP | 1 | Jul 8th, 2006 09:36 |
| problems connecting to database | benbacardi | Classic ASP | 8 | Apr 15th, 2005 16:16 |
| connecting to web-email via pop using php... | Billydakid | PHP Forum | 7 | Feb 12th, 2004 08:42 |