Click to See Complete Forum and Search --> : I can't connect ASP script with my local MS Access database


NewComer2009
10-31-2009, 06:39 PM
I would like to use ASP script to connect and open my local MS Access database, I also have the MS Access database at my c:\inetpub\wwwroot\Name_ID.mdb with have only 1 table List with 2 columns: column "Name"(defined as Text) & column "ID" (defined as Number)

I have my web-page ConnectLocalDatabase.asp at my web-site with the following codes:

<%

Dim strQuery, rsRequest, conn

set conn = CreateObject("ADODB.Connection")
conn.open "Provider=MS Remote;" &_
"Remote Server=http://27.33.22.211;" &_
"Remote Provider=Microsoft.Jet.OLEDB.4.0;" &_
"Data Source=c:\inetpub\wwwroot\Name_ID.mdb;"

set rsRequest = Server.CreateObject("ADODB.Recordset")
strQuery = "SELECT * From List Where ID= 1"

'=================================================
rsRequest.Open strQuery, conn, adOpenDynamic, adLockOptimistic, CmdTex
If Not rsRequest.EOF Then
Response.write(rsRequest("Name"))
Response.write("OK1")
End If rsRequest.Close
'=================================================

conn.Close
Response.write("OK2")

%>

If I comment-out codes between '=== ... '=== then my web-page show OK2 without any error, but when I remove those comment-out I will have web-page error

- If I connect directly with the same Name_ID.mdb on my web-site, then there is no error (sure I have to modify the "Remote Server=http://27.33.22.211;"

Note1: I even use ODBC Data Source Administrator to register the Name_ID.mdb in c:\inetpub\wwwroot\ as recomended

Note2: I did use www.showmyip.com to have my Internet address of my PC: 27.33.22.211

Can anyone help on this?

Thanks in-advanced

verikal
11-09-2009, 05:49 PM
Are you using user and password ?

ssystems
11-09-2009, 06:20 PM
First your are able to connect. If you look carefully the problem is not on the database connection but on rendering/retrieving the recordset.


set rsRequest=Server.CreateObject("ADODB.recordset")
rsRequest.Open strQuery, conn, adOpenDynamic, adLockOptimistic, CmdTex

for each x in rsRequest.fields
response.write(x.name)
response.write(" = ")
response.write(x.value)
next
rsRequest.Close

verikal
11-09-2009, 06:46 PM
I don't think this is the problem.
strQuery = "SELECT * From List Where ID= 1"
Can you post the error message you get ?

stevepugh
11-14-2009, 12:16 PM
Why don't you use a DSN. Simply set up system DSN to the ms access db and then create a very simple connection form your web page to the dsn.