How to output MySQL value to your data table

上一篇 / 下一篇  2006-12-22 02:33:24 / 个人分类:QTP

When we test our applications, we may want to check how the application performs the same operations with multiple sets of data. In general we use different set of data from data table to parameter test. So, here is the way how to select data from MySQL database and insert to data table.

 **************************************************************************************************

SetConn= CreateObject("ADODB.Connection" )

'Set cmd = CreateObject("adodb.command")

 str="DRIVER={MySQL ODBC 3.51 Driver};SERVER=webdev;DATABASE=intranet;user id=root; password=xxxxxx"

Conn.open str

Set Rs = CreateObject ("ADODB.Recordset" )

sql = "select * from `user` limit 1;"

Rs.open sql,conn,1,3

 While Not Rs.eof

    For i=1 to 6

            '**********  write to data table

           DataTable("Intranet_user"&i,"Global") = Rs(i)

      next

            Rs.movenext

            DataTable.Export ("C:\user.xls")

wend

Rs.close

Set Rs = Nothing

Conn.close

SetConn= Nothing

 *************************************************************************************** 


TAG: QTP

 

评分:0

我来说两句

我的栏目

日历

« 2024-04-23  
 123456
78910111213
14151617181920
21222324252627
282930    

数据统计

  • 访问量: 3785
  • 日志数: 7
  • 建立时间: 2006-12-19
  • 更新时间: 2008-10-17

RSS订阅

Open Toolbar