QTP往MYSQL数据库插数据
'Dim URLDim linkStatue
Dim linktime
URL="wenku.baidu.com"
Set control=CreateObject("HttpWatch.Controller")
Set plugin=control.IE.New()
plugin.Log.EnableFilter(false)
plugin.Clear()
plugin.Record()
plugin.GotoURL(URL)
wait(2)
'Browser("中国移动通信").Page("中国移动通信").Link("我的移动").Click
ip = plugin.log.Entries.Item(0).ServerIP '获取iP地址
code = plugin.Log.Entries.Item(0).StatusCode '获取状态码
linktime = plugin.log.Entries.Summary.Time '获取响应时间
'inputbox(linktime)
Dim Conn
Set Conn=CreateObject("ADODB.Connection") '创建连接
Const ConnectionString="Driver={Mysql ODBC 5.1 Driver};DATABASE=shanxiyidong;PWD=sa;PORT=3306;SERVER=127.0.0.1;UID=root"
Conn.Open ConnectionString
'连接数据库_增删改
Dim strSql,i,a '定义变量
strSql= "insert into zhangting(测试号码) values ('151')" '设置插入语句
Conn.Execute strSql '执行SQL语句
If 10>linktime Then
Reporter.ReportEvent micPass,"响应时间","少于10秒:"&linktime
else
Reporter.ReportEvent micFail,"响应时间","大于10秒:"&linktime
End If
strSql= "insert into zhangting(受理时长) values('"+linktime+"')" '设置插入语句
'strSql= "update zhangting set 受理时长='"+linktime+"' where 测试号码='151'" '修改编号
Conn.Execute strSql '执行SQL语句
'停止记录Http底层数据
plugin.Stop
'关闭浏览器窗口
plugin.CloseBrowser()
'回收对象
Set control=nothing
Set plugin=nothing
Set sumary=nothing
'获取页面响应时间;;;在这行报错
strSql= "insert into zhangting(受理时长) values('"+linktime+"')"
提示:
类型不匹配: '但是换成输出ip却是可以的 试试用&
strSql= "insert into zhangting(受理时长) values('"&linktime&"')" 试试用strSql= "insert into zhangting(受理时长) values('"&linktime&"')"
页:
[1]