If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Using a variable in a db connection string

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-22-04, 00:02
breeze76 breeze76 is offline
Registered User
 
Join Date: Apr 2004
Posts: 75
Exclamation Using a variable in a db connection string

I would like to use a variable in my db connection string. Here is what I have:

conn.Open "driver={Microsoft Access Driver (*.mdb)};;dbq=C:\inetpub\projects\; & 'database'"

This does not work. "Database" is a query I am pulling from another page that is the database name with the extension. How do I put it in the connection string?

Thanks
Reply With Quote
  #2 (permalink)  
Old 10-22-04, 00:07
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
Soemthing more like this perhaps......
Code:
conn.Open "driver={Microsoft Access Driver (*.mdb)};;dbq=C:\inetpub\projects\" & database
Reply With Quote
  #3 (permalink)  
Old 10-22-04, 00:15
breeze76 breeze76 is offline
Registered User
 
Join Date: Apr 2004
Posts: 75
Quote:
Originally Posted by rokslide
Soemthing more like this perhaps......
Code:
conn.Open "driver={Microsoft Access Driver (*.mdb)};;dbq=C:\inetpub\projects\" & database
Tried that, still does not work. This is the error I get when I do that:
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x304 Thread 0x61c DBC 0x2925f54 Jet'.
/project_info.asp, line 70

Line 70 in the db connection string...

any other suggestions??
Reply With Quote
  #4 (permalink)  
Old 10-22-04, 00:37
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
can you do a response.write on your connection string eg
Code:
response.write "driver={Microsoft Access Driver (*.mdb)};;dbq=C:\inetpub\projects\" & database 
conn.Open "driver={Microsoft Access Driver (*.mdb)};;dbq=C:\inetpub\projects\" & database
so we can see what is actually being built??
Reply With Quote
  #5 (permalink)  
Old 10-22-04, 00:52
breeze76 breeze76 is offline
Registered User
 
Join Date: Apr 2004
Posts: 75
that gives me the same error..

Hmmmmm
Reply With Quote
  #6 (permalink)  
Old 10-22-04, 00:56
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
yes, it would have given you the same error, but is should have also written out the complete connection string that you are trying to use so that you could post it here and we could see what was wrong with it.....

I would have expected you would want something like this for you connection string
Code:
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
           "Data Source=c:\somepath\myDb.mdb;"
rather then
Code:
conn.Open "driver={Microsoft Access Driver (*.mdb)};;dbq=C:\inetpub\projects\" & database
so you might want to try
Code:
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
           "Data Source=c:\somepath\" & Database & ";"
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On