|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Error: Cast From String to type Integer not validcmSQL = New SqlCommand("nf_AddPurchaseOrder", cnSQL) cmsql.CommandType = CommandType.StoredProcedure cmsql.Parameters.Add("@PurchaseOrderId", sqldbtype.varchar, 10, "OrderNo").Value = txtPONum.Text cmsql.Parameters.Add("@OrderDesc", sqldbtype.VarChar , 50 , "OrderDesc").Value = txtOrderDescription.text cmsql.Parameters.Add("@SupplierId", sqldbtype.Int , "SupplierId").Value = s.SupplierId Dim b as Program b = cmbPrograms.SelectedItem cmsql.Parameters.Add("@ProgramId", sqldbtype.Int , "ProgramId").Value = b.ProgramId When the code hits either the SupplierId or the ProgramId line I get the following error: Cast from String "SupplierId" to type 'Integer' is not valid My problem is that the stored procedures parameters are Int, the values I'm passing in are also Integers. So not sure where the heck this error is coming from. Thanks for any help. Michael Lee Michael,
VBNet has those nice conversions methods. dim a as integer = Cint("1") is all you have to do to make from a string containing only numbers and by instance decimal points a nice integer. I hope this helps, Corn Hi Cor,
Thanks for the reply. I just found the problem, it was my mistake. If I change the following code: cmsql.Parameters.Add("@SupplierId", sqldbtype.Int , "SupplierId").Value = s.SupplierId TO: cmsql.Parameters.Add("@SupplierId", sqldbtype.Int).Value = s.SupplierId It works fine. I had gotten the wrong overloaded method. Thanks for the reply. Michael Show quoteHide quote "Cor Ligthert" wrote: > Michael, > > VBNet has those nice conversions methods. > > dim a as integer = Cint("1") is all you have to do to make from a string > containing only numbers and by instance decimal points a nice integer. > > I hope this helps, > > Corn > > > |
|||||||||||||||||||||||