欢迎大家光临我的空间,希望能跟大家成为好朋友。

『傻瓜版2』用QTP连接Oracle DB

上一篇 / 下一篇  2008-05-30 16:24:38 / 个人分类:QTP

方法2: 用代码实现QTP与Oracle DB的连接。

Dim Cnn
Dim Rst
Dim strCnn
strCnn="Provider=OraOLEDB.Oracle.1;Data Source=数据库名;Password=登录密码;User ID=登录用户名;Persist Security Info=True;"

(得出方法参考一下链接:

http://bbs.51testing.com/viewthread.php?tid=107598&highlight=DB%2B%CA%FD%BE%DD%BF%E2

Set Cnn = CreateObject("ADODB.Connection")
Cnn.Open strCnn
Set Rst =CreateObject("ADODB.Recordset")
Rst.open "select column_name  from table_name where **** ", Cnn
i=1 
While not Rst.eof       '//循环取出DB里面的数据并导到Global table里面
     dim1=Rst("para1").value
     dim2=Rst("para2").value   
     DataTable.GlobalSheet.SetCurrentRow(i)
     DataTable("Dim1",dtGlobalSheet)=dim1
     DataTable("Dim2",dtGlobalSheet)=dim2     
i=i+1
    Rst.movenext                 
wend


TAG: QTP

 

评分:0

我来说两句

Open Toolbar