Click here to Skip to main content
15,911,531 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
so i have stored procedure Update that has some values and i am using it
C#
fa.Update_Person(Convert.ToInt32(e.Keys["ID"]),e.NewValues["FIRST_NAME"].ToString(), e.NewValues["LAST_NAME"].ToString(), e.NewValues["Alt_Firstname"].ToString(), e.NewValues["Alt_Surname"].ToString(), e.NewValues["PHONE_WORK"].ToString(), e.NewValues["PHONE_HOME"].ToString(), e.NewValues["MOBILE"].ToString(), e.NewValues["FAX"].ToString(), e.NewValues["EMAIL"].ToString(), DateTime.Now, e.NewValues["Note"].ToString(), DateTime.Now,e.NewValues["Position"].ToString(),Convert.ToInt32(e.NewValues["Company_ID"]), Convert.ToInt32(e.NewValues["Country_id"]),Convert.ToInt32(e.NewValues["City_id"]),e.NewValues["State"].ToString(), e.NewValues["Adress"].ToString(), e.NewValues["Zip_Code"].ToString(), Convert.ToInt16(e.NewValues["Group_Id"]));


like this City-Id is INt and Position is String but i get error on 2 of this that
C#
cannot convert from 'string' to 'int?'

can you help me out?
Posted
Comments
Michael_Davies 28-Dec-15 2:56am    
What value is in City_id?
GTR0123 28-Dec-15 2:57am    
only int values
Michael_Davies 28-Dec-15 3:02am    
Okay, however convert.toint32 works so long as the input is numeric.

Before you execute the update look at the value in City_id and all the other values you are converting to int32 one of them must have a wrong value, maybe Null, to cause the error.
GTR0123 28-Dec-15 3:12am    
i debuged but there is nothig it is erroring me without debug if i change city_id to convert int32 it is erroring instantly but when i make it tostring() it not erroring..... if city_id is tostring() it going on Catch buuut Update command is working it is updating
Hemant Singh Rautela 28-Dec-15 8:04am    
just show us Update_Person code ! & your input values also for this fuction....

& stored procedure code

1 solution

You have to use the debugger, you know.
Either City_id is actually meant to be a descriptive string (e.g. "N.Y.") so there is logical error in your program or it should have been the string representation of a number (a bad practice, anyway) but was badly filled (e.g. "124W").
 
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