Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mess connecting to simple database 2

Status
Not open for further replies.

EvertonFC

Technical User
Nov 24, 2004
107
GB
Hello

I am getting into an irritable mess (!) connecting to a simple MSAccess database with a few photos in it.

The error message I am getting is:

Microsoft VBScript compilation error '800a0401'

Expected end of statement

/samples/dbconn.asp, line 6

DbCon = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="D:\business\graphic.com\private\gallery.mdb;"
-------------------------------------------------------^

The code I was hoping to use is:

<%
Dim DbCon
Dim objRec
Dim objCon

DbCon = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="D:\business\graphic.com\private\gallery.mdb;"

DefaultDir="& Server.MapPath(".") &";DriverId=25;FIL=MS Access;MaxBufferSize=512;PageTimeout=5"


%>

When I have asked my server host, they just ask me to ensure I have the MDB in a folder called 'Private', which I have!

Many thanks

EvertonFC


 
try this:

"DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("gallery.mdb")

-DNG
 
DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../gallery.mdb")

-DNG
 
Sorry, DNG, but I am now getting this:

Microsoft VBScript compilation error '800a0400'

Expected statement

/samples/dbconn.asp, line 6

"DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../gallery.mdb")
^

The code responsible is as follows:

<%
Dim DbCon
Dim objRec
Dim objCon

"DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../gallery.mdb")


%>

Cheers!
 
How does the code know where to look for the file when you use this method? (since no path is specified?)
 
The reason it is saying "expected end of statement" is that you've got three quotation marks in the string.

DbCon = [red]"[/red]DRIVER={Microsoft Access Driver (*.mdb)};DBQ=[red]"[/red]D:\business\graphic.com\private\gallery.mdb;[red]"[/red]


 
I understand...sort of. But what do I do if the database is on another server? Do I need to map a drive? If so, how would the code change?
 
Many thanks

This worked:

DbCon = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=D:\business\graphic.com\private\gallery.mdb;"

Best regards - and thanks DNG for the links. Plenty of reading!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top