Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_database_setup thread: Problems connecting to an Access DB via OLE DB


Message #1 by "paul pimentel" <ppimentel@c...> on Mon, 18 Feb 2002 21:49:08
We are trying to connect to an Access database on the webserver. We are 

receiving errors referring to the path being incorrect. We tried first 

with a DNS and have now switched to DNS-less, and the same pages work when 

trying to connect to a SQL db. We've tried it with the ODBC and with the 

OLE Db with no success. Any help is greatly appreciated.



'set conn = server.createobject("ADODB.Connection")

'connectstring = "Driver={Microsoft Access Driver (*.mdb)};DBQ =" & 

Server.MapPath("halliburton.mdb")

'conn.Open connectstring



'Set Conn = Server.CreateObject("ADODB.Connection")

'Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & 

Server.MapPath("\wwwroot\halliburton\halliburton\halliburton.mdb")



Set Conn = Server.CreateObject("ADODB.Connection")

connectstring = "Provider=Microsoft.Jet.OLEDB.4.0;" & _

"Data Source=c:\inetpub\wwwroot\halliburton\halliburton\halliburton.mdb;" 

& _

"User Id=admin;" & _

"Password=;"



conn.Open connectstring











If conn.Errors.Count > 0 Then



	For Each ConnErrorsFound in Conn.Errors

		If ConnErrorsFound.NativeError <> 5701 and 

ConnErrorsFound.NativeError <>  5703 Then



			str_ErrMsg = "Unable to connect to the database. 

<br>"

			str_ErrMsg = str_ErrMsg & "Error Number: " & 

ConnErrorsFound.Number & "-"

			str_ErrMsg = str_ErrMsg & "Description: " & 

ConnErrorsFound.Description



		End If



	Next



	If ConnErrors then



		conn.close

		set conn = Nothing

		Response.Write str_ErrMsg



	End if

End If



part1 = "SELECT IVR_ID.A, Packet_contact.A, First_name.A, Last_Name.A, 

Packetadd1.A"

part1 = part1 & " FROM Halliburton_duplicate A, Orders_duplicate B"



part2 = " WHERE IVR_ID.A = IVR_ID.B and "

part2 = part2 & searchfield & " = '" & searchtext & "'"



part3 = " ORDER BY Last_Name"



stmt = part1 & part2 & part3







Set rs = Server.CreateObject("ADODB.Recordset")

rs.Open stmt, conn, , , adCmdText





%>

			
Message #2 by "Drew, Ron" <RDrew@B...> on Mon, 18 Feb 2002 21:39:34 -0500
Is the MDB in the root directory wwwroot?  If not the mappath needs ..

Server.MapPath("..\halliburton\halliburton\halliburton.mdb")



-----Original Message-----

From: paul pimentel [mailto:ppimentel@c...]

Sent: Monday, February 18, 2002 4:49 PM

To: ASP Database Setup

Subject: [asp_database_setup] Problems connecting to an Access DB via

OLE DB





We are trying to connect to an Access database on the webserver. We are

receiving errors referring to the path being incorrect. We tried first

with a DNS and have now switched to DNS-less, and the same pages work

when

trying to connect to a SQL db. We've tried it with the ODBC and with the



OLE Db with no success. Any help is greatly appreciated.



'set conn =3D server.createobject("ADODB.Connection")

'connectstring =3D "Driver=3D{Microsoft Access Driver (*.mdb)};DBQ =3D" 

&

Server.MapPath("halliburton.mdb")

'conn.Open connectstring



'Set Conn =3D Server.CreateObject("ADODB.Connection")

'Conn.Open "DRIVER=3D{Microsoft Access Driver (*.mdb)}; DBQ=3D" &

Server.MapPath("\wwwroot\halliburton\halliburton\halliburton.mdb")



Set Conn =3D Server.CreateObject("ADODB.Connection")

connectstring =3D "Provider=3DMicrosoft.Jet.OLEDB.4.0;" & _

"Data

Source=3Dc:\inetpub\wwwroot\halliburton\halliburton\halliburton.mdb;"

& _

"User Id=3Dadmin;" & _

"Password=3D;"



conn.Open connectstring











If conn.Errors.Count > 0 Then



	For Each ConnErrorsFound in Conn.Errors

		If ConnErrorsFound.NativeError <> 5701 and

ConnErrorsFound.NativeError <>  5703 Then



			str_ErrMsg =3D "Unable to connect to the database.



<br>"

			str_ErrMsg =3D str_ErrMsg & "Error Number: " &

ConnErrorsFound.Number & "-"

			str_ErrMsg =3D str_ErrMsg & "Description: " &

ConnErrorsFound.Description



		End If



	Next



	If ConnErrors then



		conn.close

		set conn =3D Nothing

		Response.Write str_ErrMsg



	End if

End If



part1 =3D "SELECT IVR_ID.A, Packet_contact.A, First_name.A, Last_Name.A, 



Packetadd1.A"

part1 =3D part1 & " FROM Halliburton_duplicate A, Orders_duplicate B"



part2 =3D " WHERE IVR_ID.A =3D IVR_ID.B and "

part2 =3D part2 & searchfield & " =3D '" & searchtext & "'"



part3 =3D " ORDER BY Last_Name"



stmt =3D part1 & part2 & part3







Set rs =3D Server.CreateObject("ADODB.Recordset")

rs.Open stmt, conn, , , adCmdText





%>

		=09




$subst('Email.Unsub')






$subst('Email.Unsub').


  Return to Index