QTP链接数据库

上一篇 / 下一篇  2009-03-27 17:51:31 / 个人分类:QTP脚本

*********************************************************
'连接数据库
'*********************************************************
Dim conn,res,strSql ,strSqll ,numbe '定义变量
On error resume next
set conn = CreateObject("ADODB.Connection")   '创建连接
conn.ConnectionString="Provider=MSDAORA.1;Password=Password;Persist Security Info=True;User

ID=id;Data Source=192.168.0.1:****/source;"   '设置连接字符串
conn.open  '开启连接

If conn.state=0 Then   '如果连接状态为0,表示连接失败,写入reporter对象中,否则表示连接成功
    Reporter.ReportEvent micFail,"testing","数据库连接失败"
    res.close                               '关闭结果集和连接,并且置为空
    Set res = nothing
    conn.close
    Set conn = nothing
else
   Reporter.ReportEvent micPass,"testing","数据库连接成功"


TAG:

 

评分:0

我来说两句

我的栏目

日历

« 2024-04-17  
 123456
78910111213
14151617181920
21222324252627
282930    

数据统计

  • 访问量: 854
  • 日志数: 2
  • 建立时间: 2008-12-10
  • 更新时间: 2009-03-27

RSS订阅

Open Toolbar