Monday, 29 December 2014

QTP - Sql Server 2005 Connections



Option Explicit
Dim con,rs, i

Set con=createobject("adodb.connection")
Set rs=createobject("adodb.recordset")

con.Open"Provider=sqloledb;Server=SYS;Database=csr_db;uid=sa;pwd="
rs.open "select * from csr1",con
i=0
MsgBox rs.Fields.Count
Do while not rs.eof
    print "Row  :  "&i
    print rs.fields(0).Name &" : "&  rs.fields(0).Value
    print rs.fields(1).Name &" : "&  rs.fields(1).Value
    print rs.fields(2).Name &" : "&  rs.fields(2).Value
    rs.movenext
    i = i+1
Loop

'Release objects'Release objects
Set rs= nothing
Set con= nothing

No comments:

Post a Comment