Connecting to a DB via ADODB 
Author Message
 Connecting to a DB via ADODB

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



Fri, 09 Feb 2001 03:00:00 GMT  
 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



Sat, 10 Feb 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. problem connect to ADODB!!

2. Problem: can't connect to a DB within a Subroutine

3. Help, plz, problems connecting to db second time

4. Connecting To Acces DB Over The NET

5. Connect to DB with JavaScript

6. Connecting to an Oracle DB

7. connect to db

8. Connect to Secure Access DB with ADO

9. Can VBScript under WinScriptHost connect to Access db without Access being installed on the workstation

10. Connect Access DB use vbscript

11. Wildcard syntax for DTC parameter connected to access db

12. Connect to local DB though ASP?

 

 
Powered by phpBB® Forum Software