Script to Import Data From Database to Datatable in QTP

Dim con,rs
Set con=createobject("adodb.connection")
Set rs=createobject("adodb.recordset")
con.provider="microsoft.jet.oledb.4.0"
con.open"d:\db.mdb"
rs.open"select*from Stud",con
datatable.GetSheet(1).addparameter"STUD_NO",""
datatable.GetSheet(1).addparameter"STUD_NAME",""
datatable.GetSheet(1).addparameter"STUD_PAY",""
row=1
Do While Not rs.EOF
datatable.SetCurrentRow(row)
datatable.Value (1,1)=rs.fields("studno")
datatable.Value(2,1)=rs.fields("studname")
datatable.Value(3,1)=rs.fields("studpay")
row=row+1
rs.movenext
Loop

But this is not a very good approach for this.We need to discuss more on this.
Script to Import Data From Database to Datatable in QTP Script to Import Data From Database to Datatable in QTP Reviewed by Animesh Chatterjee on December 21, 2008 Rating: 5

No comments:

Powered by Blogger.