51Testing软件测试论坛
标题:
qtp求教
[打印本页]
作者:
wdlcoke
时间:
2010-8-6 10:45
标题:
qtp求教
***qtp咋样从数据库里取值???
作者:
TIB
时间:
2010-8-6 14:03
要看什么数据库,一般通过ADO可连接,下面是SQLServer的例子:
Dim Conn
Dim Rst
Dim str_Link_DBSource
str_Link_DBSource="Provider=SQLOLEDB.1;Password=sa;Persist Security Info=True;User ID=sa;Initial Catalog=Northwind;Data Source=TEST"
Set Conn=CreateObject("ADODB.Connection")
Conn.Open str_Link_DBSource
Set Rst=CreateObject("ADODB.Recordset")
Rst.Open "select * from Orders",Conn,2,2
Rst.MoveFirst
Do While Rst.Eof<>true
Print Rst.Fields(0) & " " & Rst.Fields(1) & " " & Rst.Fields(2)
Rst.MoveNext
Loop
Rst.Close
Conn.Close
Set Rst=Nothing
Set Conn=Nothing
复制代码
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/)
Powered by Discuz! X3.2