Click to See Complete Forum and Search --> : Input string was not in a correct format.
kunal.kb
September 15th, 2005, 02:16 AM
can any one help me.....
i am getting an error "Input string was not in a correct format. "
i have created a stored procedure....
passing the parameters but while "SqlCmd.ExecuteNonQuery()"
this error comes.....
i checked the data types......
but i don't know why this error is coming...
plz help.....
HanneSThEGreaT
September 15th, 2005, 02:32 AM
Please post the code :)
kunal.kb
September 15th, 2005, 02:57 AM
For i = 0 To a - 1
SqlCmd = New SqlCommand("update_IRProfile", SqlCon)
SqlCmd.CommandType = CommandType.StoredProcedure
>>viewstate("g") = Request.Form("txta" & i).ToString()
>>viewstate("g1") = Request.Form("txtb" & i).ToString()
SqlCmd.Parameters.Add("@AAttr", SqlDbType.Char, 4).Value = lookup.SelectedItem.Text.ToString()
>>SqlCmd.Parameters.Add("@VValue", SqlDbType.Int).Value = CStr(viewstate("g"))
>>SqlCmd.Parameters.Add("@IValue", SqlDbType.Int).Value = CStr(viewstate("g1"))
SqlCmd.Parameters.Add("@Desc", SqlDbType.VarChar, 25).Value = Label1.Text.ToString()
SqlCmd.ExecuteNonQuery()
Next i
the code is here
the lines marked with >> are accepting the data from dynamically created text boxes.......
and the line "ExecuteNonQuery()" is giving the error
please tell me why this error is coming.......
TSmooth
September 15th, 2005, 07:27 AM
>>SqlCmd.Parameters.Add("@VValue", SqlDbType.Int).Value = CStr(viewstate("g"))
>>SqlCmd.Parameters.Add("@IValue", SqlDbType.Int).Value = CStr(viewstate("g1"))
Those parameters are being added as Int types but you are giving them Strings which could be causing your problem. Try chainging "CStr" to "CInt". Also, you should make sure that the values in the text boxes are indeed able to be converted using IsNumeric() or another similar method.
- Tom
kunal.kb
September 15th, 2005, 08:07 AM
Tom
i changed it.....
but it is giving some new error
"Arithmetic operation resulted in an overflow. "
and i made sure, the values in the textboxes are only numbers......
SqlCmd.Parameters.Add("@AAttr", SqlDbType.Char).Value = lookup.SelectedValue.ToString()
SqlCmd.Parameters.Add("@VValue", SqlDbType.Int).Value = CInt(viewstate("g"))
SqlCmd.Parameters.Add("@IValue", SqlDbType.Int).Value = CInt(viewstate("g1"))
SqlCmd.Parameters.Add("@Desc", SqlDbType.VarChar).Value = Label1.Text.ToString()
this is the source error
and the stack trace
[OverflowException: Arithmetic operation resulted in an overflow.]
Microsoft.VisualBasic.CompilerServices.IntegerType.FromString(String Value)
Microsoft.VisualBasic.CompilerServices.IntegerType.FromObject(Object Value)
HenCorp.WebForm3.kunal() in c:\inetpub\wwwroot\HenCorp\Exception Parameter - Inconsistent Risk Profile.aspx.vb:191
HenCorp.WebForm3.lnkUpsrecord_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\HenCorp\Exception Parameter - Inconsistent Risk Profile.aspx.vb:157
System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e)
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain()
HanneSThEGreaT
September 15th, 2005, 08:24 AM
Try converting to Long
CLng
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.