Wednesday, June 27, 2012

Example of ADODB.Connection and ADODB.Recordset in VBscript


    Set MyConn = CreateObject("ADODB.Connection")
    MdbFilePath = "C:\Users\ladn\Desktop\Neeraj.mdb"
    MyConn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & MdbFilePath & ";"

 
    SQL_query = "SELECT * from Student"
 
     set rs=CreateObject("ADODB.recordset")
     rs.Open SQL_query, MyConn
 
    count = 0
    WHILE NOT RS.EOF
count = count + 1
name = rs("name")
add = rs("address")
msgbox name & add
       rs.MoveNext
    WEND
msgbox count
    rs.Close
    set rs = nothing
    MyConn.close
    set MyConn = nothing

No comments: