Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vbscript and sql table view

Status
Not open for further replies.

mragain

IS-IT--Management
Oct 10, 2002
32
US
I have a DSN defined on a machine called 'test'. I want to use this to access the database it points to and run a defined view there called zz_wanted_data.

What methods does vbscript offer to make the connection run this view and process the data. The returned data can contain 25000 records, and each record's fields are tab delimited.

Any help will be greatly appreciate.

 
You can use the CreateObject procedure to create an ADODB object and then use that like you would in standard VB.

set adoCon = CreateObject("ADODB.Connection")
adoCon.Open(connectionstring)

set adoRs = adoCon.Execute(sqlstatement)

while not adoRs.Eof()
..
adoRs.MoveNext
wend

Greg Conely
 
I appreciate your comments. I was able to find some links that help me last night, and thought I would post the code.

Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3
strUserName = "testuser"
strPassword = "password"

Dim x
Dim objConnection, objRecordset
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")

objConnection.Open "DSN=test;", strUserName, strPassword
objRecordset.CursorLocation = adUseClient
objRecordset.Open "SELECT * FROM zz_table_view" , objConnection, adOpenStatic, adLockOptimistic

objRecordSet.MoveFirst

Do Until objRecordset.EOF
x = objRecordset.Fields("export")
fac.WriteLine x
objRecordset.MoveNext
Loop

objRecordset.Close
objConnection.Close
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top