连接数据库
上一篇 /
下一篇 2007-04-16 21:55:06
/ 个人分类:QTP
dim cnn,rst,strcnn,strsql
set cnn = createobject("adodb.connection")
set rst = createobject("adodb.recordset")
strcnn = "数据库连接字符串"
cnn.open = strcnn
strsql = "select * from table_a"
rst.open strsql,strcnn,2,2//参数为1,3时可用RECORDCOUNT取到记录总数,为2时返回-1
msgbox rst("abc") //取查询到的结果,字段名为abc的值,或第2列的值,第一列的index为0
msgbox rst(2)
rst.close
cnn.close
set rst = nothing
set cnn = nothing
Dim res,cmd,sql
Set res = createobject("adodb.recordset")
Set cmd = createobject("adodb.command")cmd.activeconnection="数据库连接字符串"
cmd.CommandType = 1
sql = "select max(order_number) as a from orders"
cmd.CommandText = sqlSet
res = cmd.execute()
Set res = nothingSet
cmd.ActiveConnection = nothing
Set cmd = nothing
数据库连接字符串可以建立UDL文件来获得
相关阅读:
- 《自动化测试工具介绍QTP篇》——新手必看 (51testing, 2007-4-10)
- QTP与回归测试 (51testing, 2007-4-05)
- QTP中一些基础代码结构累积 (51testing, 2009-8-21)
- 我来谈谈WinRunner和QTP的区别 (51testing, 2007-4-05)
- QTP中虚拟对象设置 (51testing, 2007-4-05)
- QTP中的数据库检查点 (xiaonan, 2007-4-06)
- QTP中的descriptive programming (51testing, 2007-4-06)
- 求助图片 (Sophie.zhang.cs, 2007-4-06)
- 退出循环 (sidneylover, 2007-4-16)
- 测试前预处理 (sidneylover, 2007-4-16)
收藏
举报
TAG:
QTP