Below Script is for importing database(MS Access)data to runtime 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 EMP",con
datatable.GetSheet(1).addparameter"EMP_No",""
datatable.GetSheet(1).addparameter"EMP_Name",""
datatable.GetSheet(1).addparameter"EMP_Sal",""
row=1
Do While Not rs.EOF
datatable.SetCurrentRow(row)
datatable.Value (1,1)=rs.fields("empno")
datatable.Value(2,1)=rs.fields("empname")
datatable.Value(3,1)=rs.fields("empsal")
row=row+1
rs.movenext
Loop
"db" is one of the database in MS Access and "EMP" is table in db.
EMP Table has 3 columns(empno,empname,empsal).
empno empname empsal
1 aaa 1000
2 bbb 2000
3 ccc 3000
After running the script u can see EMP table data in runtime datatable.
Output:
EMP_No EMP_Name EMP_Sal
1 aaa 1000
2 bbb 2000
3 ccc 3000
Script to Import Data From Database to Datatable in QTP
Subscribe to:
Post Comments (Atom)
3 comments:
This script was of great help. Appreciate your great effort.
Thnk you.
neetha.
Useful info!!!
qtp ebook
it will be more understandable if u write a comment for every statement about what it is doing
Post a Comment