WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

ADO DAO
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

!!! Simple ADO Example !!!


Simple ADO Read CSV Example
adOpenStatic = 3
adLockOptimistic = 3
adCmdText = 1

objConnection = CreateObject("ADODB.Connection")
objRecordSet = CreateObject("ADODB.Recordset")

strPathtoTextFile = DirScript()
textfile = "sample.csv"


objConnection.Open(StrCat('Provider=Microsoft.Jet.OLEDB.4.0;Data Source=', strPathtoTextFile,';Extended Properties="text;HDR=YES;FMT=CSVDelimited"'))  ;''
objRecordset.Open(StrCat("SELECT * FROM ",textfile), objConnection, adOpenStatic, adLockOptimistic, adCmdText)

While !objRecordset.EOF
    Message("CustID: ", objRecordset.Fields.Item("CustID").value)
    Message("First Name: ", objRecordset.Fields.Item("FirstName").value)
    Message("Last Name: ", objRecordset.Fields.Item("LastName").value)  
    objRecordset.MoveNext()
Endwhile

objRecordset.Close()
objRecordset = 0
objConnection.Close()
objConnection = 0


Sample.CSV

CustID,LastName,FirstName,Address,City,State,Zip
1000,Flintstone,Fred,1230 Stone Road,BedRock,AZ,85000
1001,Rubble,Barney,4560 Pebble Street,BedRock,AZ,85000
1002,Flintstone,Wilma,1230 Stone Road,BedRock,AZ,85000
1003,Rubble,Betty,4560 Pebble Street,BedRock,AZ,85000
1004,Ball,Lucille,55 Love Lane,TelevisionCity,CA,90201
1005,Arnez,Desi,55 Love Lane,TelevisionCity,CA,90201
1006,Boop,Betty,1930 Boop-Boop-A-Doop Loop,Hollywood,CA,90068
1007,Dean,James,1960 Desire Street,Hollywood,CA,90068
1008,Monroe,Marilyn,1962 Norma Jean Ave.,Hollywood,CA,90068
1009,Marley,Bob,333 Reggae Road,St. Ann's Parish,Jamaica,10101

Article ID:   W17102
File Created: 2007:07:03:14:28:18
Last Updated: 2007:07:03:14:28:18