I am trying to create a template in Excel for customers to bulk update a SQL Server database.
The tricky part is with a few numeric columns, for example, the one I am testing is Estimated_Amt
. The value could be null, and I tried and still cannot figure out if when it is null, how to pass the value to fee an update stored procedure.
Here's How I set up the parameter:
Estimated_Amt = .Cells(iRowNo,8)
If (.Cells(iRowNo, 8) = "") Then
cmd.Parameters.Append cmd.CreateParameter("@Estimated_Amt", adVarChar, adParamInput, DBNULL.Value)
Else
cmd.Parameters.Append cmd.CreateParameter("@Estimated_Amt", adVarChar, adParamInput, CStr(Estimated_Amt))
End If
I tried AdDouble
and AdDecimal
respectively, and never succeeded in catching without error the null or empty value, and with AdVarchar
, still didn't work out correctly
And the calling procedure part is like:
cmd.CommandText = "SP_RIBulkyUpdate @CaseNumber = " & CaseNumber & ", " & _
"@Estimated_Amt = " & Estimated_Amt
Any suggestion on setting the input parameter correctly? Thanks.