wdlcoke 发表于 2010-8-6 10:45:46

qtp求教

***qtp咋样从数据库里取值???

TIB 发表于 2010-8-6 14:03:07

要看什么数据库,一般通过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
页: [1]
查看完整版本: qtp求教