最近在做广州运管局数据整合项目的测试工作,在测试的初期是使用WinRunner实现测试数据的入库,以及数据比较的工作。在对实际数据进行比较的时候,发现WinRunner会将所有数据放入到临时页面文件中,而这个页面文件如果太大的话会因硬盘磁盘空间不足而退出。后来想到的分页的方法,但WinRunner却报拼的Sql语句长度过长,无奈下只好用QTP试验一下完成。
在QTP中,最常使用的是对数据库中数据的查询,因此查询的方法也是很多。下面就是网上获得很多人认可的方法:
Dim Conn,rs
Set Conn = createobject( " ADODB.connection " )
Set rs = createobject( " ADODB.recordset " )
Conn = " DSN=toDB;UID=sa;PWD=sa;APP=QuickTest Professional;WSID=TESTBD;DATABASE=diw "
rs.open " select count(*) actual_row from T_K_QiYeJBXX "
Dim actual_row
actual_row = rs( " actual_row " ).value
Set rs = nothing
Set Conn = nothing
Set Conn = createobject( " ADODB.connection " )
Set rs = createobject( " ADODB.recordset " )
Conn = " DSN=toDB;UID=sa;PWD=sa;APP=QuickTest Professional;WSID=TESTBD;DATABASE=diw "
rs.open " select count(*) actual_row from T_K_QiYeJBXX "
Dim actual_row
actual_row = rs( " actual_row " ).value
Set rs = nothing
Set Conn = nothing
又发现一种利用command的方式来实现数据库连接的
Dim res,cmd,sql
Set Res=createobject("adodb.recordset")
Set Cmd=createobject("adodb.command")
Cmd.activeconnection="DSN=toDB;UID=sa;PWD=sa;APP=QuickTest Professional;WSID=TESTBD;DATABASE=diw"
Cmd.CommandType = 1
sql=" update T_K_QiYeJBXX set C_ZiZhiDJ_ID = 3"
Cmd.CommandText = sql
Set res = Cmd.Execute()
'Dim deal_row
'deal_row = res("deal_row").value
'msgbox(deal_row)
Set res = nothing
Set cmd.ActiveConnection = nothing
Set Cmd= nothing
Set Res=createobject("adodb.recordset")
Set Cmd=createobject("adodb.command")
Cmd.activeconnection="DSN=toDB;UID=sa;PWD=sa;APP=QuickTest Professional;WSID=TESTBD;DATABASE=diw"
Cmd.CommandType = 1
sql=" update T_K_QiYeJBXX set C_ZiZhiDJ_ID = 3"
Cmd.CommandText = sql
Set res = Cmd.Execute()
'Dim deal_row
'deal_row = res("deal_row").value
'msgbox(deal_row)
Set res = nothing
Set cmd.ActiveConnection = nothing
Set Cmd= nothing