
Connecting to a DB via ADODB
This work s. I tested it against my WSH FAQ database
(http://wsh.glazier.co.nz )
ConnectionString="DSN=WSH;UID=gzInetAdmin;APP=WSH;WSID=BatchPC;DATABASE=WSH
;
UseProcForPrepare=0"
Set WshShell = WScript.CreateObject("WScript.Shell")
Set Conn = WScript.CreateObject("ADODB.Connection")
Conn.Open ConnectionString,"username","password"
set rsLookup = Wscript.CreateObject("ADODB.Recordset")
SQLText="SELECT * From Subject"
rsLookUp.open SQLText, Conn,0,1
Do Until RSLookup.EOF
WshShell.popup rsLookup("SubjectName")
RSLookup.MoveNext
Loop
I have always found that using a System DSN Name is easier than than a
DSN-less conection.
Regards,
Ian Morrish
http://wsh.glazier.co.nz WSHFAQ
http://ils.glazier.co.nz (NetMeeting)
http://www.glazier.co.nz
Quote:
>Can anyone tell me how to connect to a DB via ADODB using VBScript?
>I'm just trying to connect to a database and print out a column in the
>table. Right now I have the following piece of code, but it doesn't get
>past creating the object.
> ' Database connection variable
> strConn = "Driver={Microsoft Access Driver (*.mdb)};DBQ=database.mdb"
> Set Conn = WScript.CreateObject("ADODB.Connection")
> Conn.Open strConn
> sql = "SELECT * FROM table_A"
> Set RS = Conn.Execute(sql)
>-LB