0

先感谢您。我正在尝试从接受输入参数的 excel 运行存储过程,它给出了错误运行时错误“-2147217900 (80040e14)”自动化错误。

   Set cmd1 = New ADODB.Command
             With cmd1
             .ActiveConnection = sConnString
             .CommandText = "spGetPriceChangeTest"
             .CommandType = adCmdStoredProc
             .CommandTimeout = 360
             .Parameters.Append .CreateParameter("@suppliercode", adVariant, adParamInput, , Range("A" & (x + 2)).Value)
             .Parameters.Append .CreateParameter("@date1", adDBTimeStamp, adParamInput, , datetime)
             .Parameters.Append .CreateParameter("@proddescription", adVariant, adParamInput, , Range("D" & (x + 1)).Value)
             .Parameters.Append .CreateParameter("@vendorcode", adVariant, adParamInput, , Range("C" & (x + 2)).Value)
             .Parameters.Append .CreateParameter("@type", adVariant, adParamInput, , Range("B" & (x + 2)).Value)
             End With
             Set rst1 = New ADODB.Recordset
             Set rst1 = cmd1.Execute
4

2 回答 2

1

创建参数时,确保在 .CreateParameter("",adVarchar, 10 ,value)中提及 SQL 中定义的大小

这篇文章有帮助。它详细讨论了我们如何捕获错误。

https://support.microsoft.com/en-us/help/167957/info-extracting-error-information-from-ado-in-vb

于 2018-02-06T22:16:19.063 回答
0

尝试使用EXEC

.CommandText = "exec spGetPriceChangeTest"
于 2018-02-06T20:45:29.073 回答