PDA

View Full Version : Making Connection to Database


jonesd923
04-19-2006, 03:37 AM
This is my initial attempt to connect to an access database. I have no problems connecting from my localhost machine(see Rem out code), but when I put upload it to the site I get the error below.

Microsoft JET Database Engine error '80004005'

Not a valid file name.

/DatabaseConnect.asp, line 5 <%
Dim objConn, objRS, strSQL, ADO
Set objConn = Server.CreateObject("ADODB.Connection")
'objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\InetPub\wwwroot\EmpPositions\PositionDB. mdb;"
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=http://www.mydomain.net/PositonDB.mdb;"
%> I am not quite sure what I am suppose to do from the web site side. What should line 5 say (objConn.Open "?????")

bruce
04-19-2006, 06:26 AM
Change the line to

objConn.Open 'Provider=Microsoft.Jet.OLEDB.4.0; Data Source=' & server.mappath('\PositonDB.mdb')

Bruce

DiscountASP.NET
www.DiscountASP.NET (http://www.DiscountASP.NET)

allardp
07-21-2006, 01:24 AM
try this :

objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &amp; Server.MapPath("/EmpPositions/PositionDB.mdb")

(the server.mappath command maps the virtual folder to the correct physical path on the server.. this way it works both on your local server AND on the discountasp server)