我有一个按钮,可以在单击时调用数据库中的存储过程。我的VB6表格中的代码如下
Dim dbDlrID As New ADODB.Connection
Dim cmdDlrID As New ADODB.Command
Dim prm As ADODB.Parameter
Dim i As Integer
Set dbDlrID = New ADODB.Connection
With dbDlrID
.ConnectionString = "PROVIDER = MSDASQL;driver={SQL Server};database=dbname; server=servname;uid=;pwd=;"
。开
结束 Set cmdDlrID = New ADODB.Command
cmdDlrID.CommandText = "InsertLookupLog"
cmdDlrID.CommandType = adCmdStoredProc
cmdDlrID.CommandTimeout = 15
Set cmdDlrID.ActiveConnection = dbDlrID
Set prm = cmdDlrID.CreateParameter("@ContractNumberField", adVarChar, adParamInput, "HI")
cmdDlrID.Parameters.Append prm
Set prm = cmdDlrID.CreateParameter("@ContractSuffix", adVarChar, adParamInput, "HI")
cmdDlrID.Parameters.Append prm
Set prm = cmdDlrID.CreateParameter("@CustomerLastName", adVarChar, adParamInput, "HI")
cmdDlrID.Parameters.Append prm
Set prm = cmdDlrID.CreateParameter("@CustomerFirstName", adVarChar, adParamInput, "HI")
cmdDlrID.Parameters.Append prm
Set prm = cmdDlrID.CreateParameter("@Last6OfVin", adVarChar, adParamInput, "HI")
cmdDlrID.Parameters.Append prm
Set prm = cmdDlrID.CreateParameter("@DealershipName", adVarChar, adParamInput, "HI")
cmdDlrID.Parameters.Append prm
Set prm = cmdDlrID.CreateParameter("@ClaimNumber", adVarChar, adParamInput, "HI")
cmdDlrID.Parameters.Append prm
Set prm = cmdDlrID.CreateParameter("@PortalClaimNumber", adVarChar, adParamInput, "HI")
cmdDlrID.Parameters.Append prm
Set prm = cmdDlrID.CreateParameter("@RONumber", adVarChar, adParamInput, "HI")
cmdDlrID.Parameters.Append prm
Set prm = cmdDlrID.CreateParameter("@ContractID", adChar, adParamInput, "HI")
cmdDlrID.Parameters.Append prm
Set prm = cmdDlrID.CreateParameter("@LookUpUser", adVarChar, adParamInput, "HI")
cmdDlrID.Parameters.Append prm
Set prm = cmdDlrID.CreateParameter("@LookUpTime", adVarChar, adParamInput, "HI")
cmdDlrID.Parameters.Append prm
Set prm = cmdDlrID.CreateParameter("@Department", adVarChar, adParamInput, "HI")
cmdDlrID.Parameters.Append prm
cmdDlrID.Execute
Iv穿过它,在第一个参数上我得到了“运行时错误'13'类型不匹配”
ContractNumberField的类型是varchar(50)。我在这里缺少什么?
答案 0 :(得分:0)
好的我想通了,在HI和adParamInput
之间添加了“50”作为参数