K
Kev
Can anyone help me determine why I am getting the error "Object must
implement IConvertible" when I execute the stored procedure? The
exception is InvalidCastException. Below is the code. I have checked
the stored procedure, database table column datatype and the sqldbtype
and they are identical. The only thing that is not the same is the
datatype of the @col1 and @col2 parameter in the server explorer where
it is shown as "adnumeric", not sure if that is a problem or not. So I
am a little lost here. Any assistance is greatly appreciated.:
objConn.open
objCom = New SqlCommand("UPLOAD_A", objConn)
objCom.CommandType = CommandType.StoredProcedure
With objCom.Parameters
..Add("@col1", SqlDbType.Decimal, 9)
..Add("@col2", SqlDbType.Decimal, 5)
..Add("@col3", SqlDbType.VarChar, 6)
..Add("@Count", SqlDbType.Int)
End With
With objCom
..Parameters("@col1").Value = dt.Columns(0)
..Parameters("@col1").Precision = 11
..Parameters("@col1").Scale = 2
..Parameters("@col2").Value = dt.Columns(1)
..Parameters("@col2").Precision = 5
..Parameters("@col2").Scale = 4
..Parameters("@col3").Value = dt.Columns(2)
..Parameters("@Count").Direction = ParameterDirection.Output
End With
If objCom.ExecuteNonQuery() > 0 Then
'uploaded records
Dim iCount As Integer
iCount = objCom.Parameters("@Count").Value
Console.WriteLine(iCount)
Console.ReadLine()
Return True
Else
Return False
End If
implement IConvertible" when I execute the stored procedure? The
exception is InvalidCastException. Below is the code. I have checked
the stored procedure, database table column datatype and the sqldbtype
and they are identical. The only thing that is not the same is the
datatype of the @col1 and @col2 parameter in the server explorer where
it is shown as "adnumeric", not sure if that is a problem or not. So I
am a little lost here. Any assistance is greatly appreciated.:
objConn.open
objCom = New SqlCommand("UPLOAD_A", objConn)
objCom.CommandType = CommandType.StoredProcedure
With objCom.Parameters
..Add("@col1", SqlDbType.Decimal, 9)
..Add("@col2", SqlDbType.Decimal, 5)
..Add("@col3", SqlDbType.VarChar, 6)
..Add("@Count", SqlDbType.Int)
End With
With objCom
..Parameters("@col1").Value = dt.Columns(0)
..Parameters("@col1").Precision = 11
..Parameters("@col1").Scale = 2
..Parameters("@col2").Value = dt.Columns(1)
..Parameters("@col2").Precision = 5
..Parameters("@col2").Scale = 4
..Parameters("@col3").Value = dt.Columns(2)
..Parameters("@Count").Direction = ParameterDirection.Output
End With
If objCom.ExecuteNonQuery() > 0 Then
'uploaded records
Dim iCount As Integer
iCount = objCom.Parameters("@Count").Value
Console.WriteLine(iCount)
Console.ReadLine()
Return True
Else
Return False
End If