[thelist] (no subject)

NanHarbisonSmith at aol.com NanHarbisonSmith at aol.com
Sun Jun 2 10:22:00 CDT 2002


--
[ Picked text/plain from multipart/alternative ]
<snip>
> objet:
>
> i can't connect to my acces database with the asp method.
> my source code is :
>
> <%
> Set cn = CreateObject("ADODB.Connection")
> adoCon.Open ("DRIVER={Microsoft Access Driver (*.mdb)};DBQ="&
> server.mappath("/inetpub/wwwroot/itu.mdb"))
>
> sql="Select * from staff"
> Set rs=CreateObject("ADODB.recordset")
> rs.open sql, cn, 3 , 3
> rs.MoveFirst
> while not rs.eof
> response.write rs("full_name") & "
> "
> rs.moveNext
> wend
> %>
> <head>
> <title></title>
> </head>
> </snip>

Here is my code that works, copied from my files, so I have different
variable names. If I remember correctly, you have to create the connection
before you set the variable for the CreateObject assignment.

<%
option explicit
'from ADOVBS.inc
'---- CursorTypeEnum Values ----
Const adOpenForwardOnly = 0
Const adOpenKeyset = 1
Const adOpenDynamic = 2
Const adOpenStatic = 3

dim myadoconn, myadors
dim connstr
dim intRow, intCol, intFields

' a connection string for MS Access
' note that for Access, there is no userid, password, or host string

connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
connstr = connstr & "E:\INETPUB\nwind.mdb" & ";Persist Security Info=True"

set myadoconn = server.createobject("adodb.connection")
myadoconn.Open connstr

set myadors = server.CreateObject("adodb.recordset")

myadors.Open "select ProductID, ProductName, UnitPrice, UnitsInStock from
products",myadoconn,adOpenStatic
Response.Write "We have retrieved " & myadors.RecordCount &  " records"%>








More information about the thelist mailing list