Forum Moderators: open

Message Too Old, No Replies

DSN-less connection help

         

SpyderWeb

12:28 am on May 10, 2004 (gmt 0)

10+ Year Member



I need the database connection to DSN-less, can I replace
'AAA with 'BBB and have it work correctly or is 'BBB incorrect coding - I am not familiar with this layout for referencing a database.

'AAA
'Replace with your database connection information
with cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "c:\inetpub\wwwroot\email.mdb"
.Open
end with

'BBB
'Replace with your database connection information
with cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = Data Source=" & Server.MapPath("\myfolder\mydatabase.mdb")
.Open
end with

Easy_Coder

12:52 am on May 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




set cnn = server.createobject("ADODB.Connection")
cnn.open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:\anydatabase.mdb"

SpyderWeb

2:05 am on May 10, 2004 (gmt 0)

10+ Year Member



No error now with the minor corrections below:

'Replace with your database connection information
with cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString =Server.MapPath("\myfolder\mydatabase.mdb")
.Open
end with

TheDave

3:23 am on May 10, 2004 (gmt 0)

10+ Year Member



Your first one would've worked, you were just missing a quote between the first = and Data, ie:

.ConnectionString = "Data Source=" & Server.MapPath("\myfolder\mydatabase.mdb")

webdevsf

3:11 pm on May 11, 2004 (gmt 0)

10+ Year Member



Btw, server.mappath is relatively slow. you might want to put that connection string in the application object after you've constructed it, and then just use it from there.

SpyderWeb

11:01 pm on May 11, 2004 (gmt 0)

10+ Year Member



>Btw, server.mappath is relatively slow. you might >want to put that connection string in the >application object after you've constructed it, and >then just use it from there.

...after you've constructed it? Can I view physical path this why and hard code it for greater speed?

ConnectionString =Server.MapPath("\myfolder\mydatabase.mdb")

Response.write ConnectionString