Click here to Skip to main content
15,507,755 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi .. i tired to insert values in db

error is

System.ArgumentException: Cannot convert ss to System.Int32.
Parameter name: type ---> System.FormatException: Input string was not in a correct format.
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
at System.String.System.IConvertible.ToInt32(IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at System.Web.Services.Protocols.ScalarFormatter.FromString(String value, Type type)
--- End of inner exception stack trace ---
at System.Web.Services.Protocols.ScalarFormatter.FromString(String value, Type type)
at System.Web.Services.Protocols.ValueCollectionParameterReader.Read(NameValueCollection collection)
at System.Web.Services.Protocols.HtmlFormParameterReader.Read(HttpRequest request)
at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters()
at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()
Updated 18-Aug-14 20:41pm

As the error suggests, you are passing a string value into an integer type.
Hence you are getting the error.
Share this answer
for the reply that you posted to Abhinav S's solution, try replacing your code with the following:
cmd.Parameters.AddWithValue("@a", UserName);
cmd.Parameters.AddWithValue("@b", countryId);
cmd.Parameters.AddWithValue("@c", IsActive);

Bcoz you used @a,@b,@c not just a,b,c. And cmd.ExecuteNonQuery can not be assigned to int. Basically I does not return anything. In case,if the execution of "cmd" returns it is when you give "Select" Command. And also we use datareader in that case.
Hope it Works for you :)
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900