本文介绍了需要帮助无法从'string'转换为'int?'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 所以我的存储过程Update有一些值,我正在使用它 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 [ 地址]。ToString(),e.​​NewValues [ Zip_Code]。ToString(),兑换.ToInt16(e.NewValues [ Group_Id])); 喜欢这个City-Id是INt而Position是String但是我得到2的错误 无法从 ' string'转换 ' int?' 你能帮忙吗?我出去了?解决方案 你必须使用调试器。 City_id 实际上是一个描述性的字符串(例如 NY )所以你的程序中存在逻辑错误,或者它应该是数字的字符串表示形式(反正是一种不好的做法)但是填写错误(例如 124W)。 so i have stored procedure Update that has some values and i am using itfa.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 thatcannot convert from 'string' to 'int?' can you help me out? 解决方案 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"). 这篇关于需要帮助无法从'string'转换为'int?'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-11 09:45