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 > Changing server.MapPath to "driver, etc"

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-22-08, 10:40
Quetzal Quetzal is offline
Registered User
 
Join Date: Feb 2006
Posts: 51
Changing server.MapPath to "driver, etc"

Hello

I often see connection strings to MS Access databases written in this format:

Code:
'Build connection
	set conn = server.CreateObject ("ADODB.Connection")
	conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath ("users.mdb")
	set rs = server.CreateObject ("ADODB.Recordset")
Unfortunately, it's one which my hosting services does not like, preferring instead this format:

Code:
conn.Open "driver={Microsoft Access Driver (*.mdb)};DBQ=D:\business\users.mdb;"
How is it best (or easiest) to translate the first type of connection to the second?

Can I simply change:

Code:
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath ("users.mdb")
to:

Code:
conn.Open "driver={Microsoft Access Driver (*.mdb)};DBQ=D:\business\users.mdb;"
Thanks for any advice.

Steve
Reply With Quote
  #2 (permalink)  
Old 12-23-08, 03:23
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Hey Steve,
Quote:
Originally Posted by Quetzal
Can I simply change:
to:
I don't see why not! Think of the connection string as a way of telling your front-end where to look for it's data and if necessary how to authenticate to retrieve any data.

A good test would be to simply write teh value from your Server.MapPath to screen and see what is returned!

Merry Christmas
__________________
George
Twitter | Blog
Reply With Quote
  #3 (permalink)  
Old 12-24-08, 03:49
Quetzal Quetzal is offline
Registered User
 
Join Date: Feb 2006
Posts: 51
Many thanks for your reply, George.

I'll try it out!

Merry Christmas to you, too!

Steve
Reply With Quote
  #4 (permalink)  
Old 12-26-08, 21:05
SimonMT SimonMT is offline
Registered User
 
Join Date: Sep 2006
Posts: 265
Anyone who uses FSO uses server.mappath. As includes can not be dynamic FSO is the only means of "attaching" content in a file depending on the content on the page.

You could try:

Application("my_conn") = "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE= [the physical path and Users.mdb]

Simon
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