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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connection error! Arrrgghhh! 2

Status
Not open for further replies.

LoopDemon

Programmer
Nov 26, 2004
4
GB
hi could do with some help!

Can anyone see the problem with this code? I'm trying to connect to db etc. I've had it working b4 but now keep getting an error about commantext?

my code

'Open the connection to the the Access database
Set objConn = Server.CreateObject("ADODB.Connection")
MdbFilePath = Server.MapPath("cddb.mdb")
objConn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & MdbFilePath & ";"
'create and setup the Command object.
Set objCmd = Server.CreateObject("ADODB.Command")
Set objCmd.ActiveConnection = objConn
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.CursorLocation = adUseClient
objRS.CursorType = adOpenStatic
objRS.CacheSize = intPageSize

Cheers dudes.
 
You shouldn't have any drive letters or UNC in a Server.MapPath argument (pkailas). The idea behind that function is to take a virtual web path and convert it into a fixed path based on the virtual directory setup in IIS.

I have had troubles in the path using the connectrion string format your currently using. You may have better luck with using an OLEDB connection, like so:
Code:
Dim conn_str
conn_str = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
	"Data Source=" & MdbFilePath & ";" & _
	"Persist Security Info=False"

Additionally the connection object has it's own error collection you can scan through:
Code:
Dim errObj
For Each errObj in objConn.Errors
   Response.Write "<b>Error:</b> " & errObj.Number & " - " errObj.Description & "<br/>"
Next

Hope that helps and that my rusty ASP was to far off :) (so far today I have used C#, ASP.Net stuff, Python, and a little Perl, so I'm in a state of mild confusion right now :p )

-T

barcode_1.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top