QTP用ADO连接Excel表不能更新表里的数据
如题目所说的,我的脚本如下:Dim Sql_Connection,Sql_Command, Obj_Excel,Obj_EData
Sql_Connection="DSN=Excel Files;DBQ="&Environment.Value("TestDir")&"\..\cases\"&ExcelFile&".xlsx"
Sql_Command="Select * From ["&Sheetname&"$]"
Set Obj_Excel=CreateObject("ADODB.Connection")
Obj_Excel.Open Sql_Connection
Set Obj_EData=Obj_Excel.Execute(Sql_Command)
Obj_EData.MoveFirst
While Not Obj_EData.EOF
If Obj_EData.Fields("OperateType").Value = "AddEvent" and IsNumeric(Trim(Obj_EData.Fields("ShortCut").Value)) Then
Obj_EData.Fields("DataStatus").Value = "Pass"
End If
Obj_EData.Fields("DataStatus").Value = Empty
Obj_EData.MoveNext
Wend
ClearObject
运行QTP到Obj_EData.Fields("DataStatus").Value = "Pass"时会弹出提示框,如图所示,请问如何解决呢
参见以下代码
Dim rst As ADODB.Recordset
Dim cnn As New ADODB.Connection
Set rst = New ADODB.Recordset
Set cnn = CurrentProject.Connection
rst.Open strsql, cnn, adOpenKeyset, adLockOptimistic
jingzizx 发表于 2015-7-17 16:20
参见以下代码
Dim rst As ADODB.Recordset
Dim cnn As New ADODB.Connection
我自己像你这样实践了一下,感觉还是不是很懂,能否给个具体点的例子我看看吗??谢谢了~~ 已解决了,谢谢~~~~~
页:
[1]