Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

New to Databases with ASP...

0 views
Skip to first unread message

Remi Lavictoire

unread,
Sep 24, 2000, 3:00:00 AM9/24/00
to
Hi there,

I'm teaching myself ASP and setting up a database with Access that I can hit
through a web front. I'm using Windows2000 Professional with IIS (PWS). I
need a clear example of the VB Script code I'll need to open a connection to
the database (address.mdb)

Any help will be greatly appreciated!

Thanks,

Rem
r...@nisa.net

Kumar K.

unread,
Sep 24, 2000, 3:00:00 AM9/24/00
to
You need a database with a DSN name 'pwd'.
A table named 'table' and a field named 'field1'

<hmtl><body>
<%
Set DataConn = Server.CreateObject("ADODB.Connection")
DataConn.Open "DSN=pwd"
Set DataCmd = Server.CreateObject("ADODB.Command")
DataCmd.CommandText = "SELECT field1 FROM table"
Set DataCmd.ActiveConnection = DataConn
Set rst = Server.CreateObject("ADODB.Recordset")
rst.Open DataCmd,,,,adCmdText

do while not rst.EOF
response.write rst("field1")
rst.movenext
loop
%>
</body></html>

I generally use the above to connect, you could make do with a lot
less commands. Most of the stuff that you don't create explicitly will be
done
implicitly.

If you can't use a DSN then instead of DataConn.Open "DSN=pwd", use :
DataConn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" &
server.MapPath("database.mdb")
where the mdb file must be in the same directory as the asp file.

Remi Lavictoire <r...@nisa.net> wrote in message
news:Wfiz5.11150$x6.7...@news1.gvcl1.bc.home.com...

0 new messages