我无法通过JScript更新TestComplete中的.xlsx工作表,因为我收到以下错误“没有给出一个或多个必需参数的值。”
connStr = Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\TestComplete 9 Projects\AWS-R Project Suite\TestData\TS_003.xlsx;Extended Properties="Excel 12.0;ReadOnly=False;HDR=Yes;"
sSQLQuery = UPDATE [TC_PlaceVectorOrder_001$] SET [Result] = Pass where [No] = 1;
objConn = Sys.OleObject("ADODB.Connection");
objConn.Open(connStr);
recset = objConn.Execute(sSQLQuery); ///this line throws the exception
objConn.Close();
答案 0 :(得分:2)
中的字符串文字
sSQLQuery = UPDATE [TC_PlaceVectorOrder_001$] SET [Result] = Pass where [No] = 1;
必须引用:
sSQLQuery = "UPDATE [TC_PlaceVectorOrder_001$] SET [Result] = Pass where [No] = 1";
然后,很明显“Pass”既可以是文字字符串/ varchar值,也可以是包含要存储的值的变量。在第一种情况下,请尝试
sSQLQuery = "UPDATE [TC_PlaceVectorOrder_001$] SET [Result] = 'Pass' where [No] = 1";
在第二个,尝试
sSQLQuery = "UPDATE [TC_PlaceVectorOrder_001$] SET [Result] = '" + Pass + "' where [No] = 1";
UPDATE查询不应返回结果集;所以只需执行:
objConn.Execute(sSQLQuery);