输入字符串的格式不正确。确保方法参数的格式正确

dunchange 2009-04-21 11:49:03
SqlCommand cmd = new SqlCommand("Update dbo.guestInfo set Reply = '"+ this.txtContent.Text+"' where ID = "+ int.Parse(ID) +"", conn);

说我输入的字符串格式不正确,请帮忙啊
...全文
124 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
pennymay 2009-04-21
  • 打赏
  • 举报
回复

SqlCommand cmd = new SqlCommand("Update dbo.guestInfo set Reply = '"+ this.txtContent.Text+"' where ID = '"+ int.Parse(ID) +"'", conn);

dunchange 2009-04-21
  • 打赏
  • 举报
回复
不对啊会提示新的问题啊
dunchange 2009-04-21
  • 打赏
  • 举报
回复
ID是 int类型的
zgke 2009-04-21
  • 打赏
  • 举报
回复
SqlCommand cmd = new SqlCommand("Update dbo.guestInfo set Reply = '"+ this.txtContent.Text+"' where ID = "+ ID.ToString() +"", conn);


ID是什么类型的?
LemIST 2009-04-21
  • 打赏
  • 举报
回复
int.Parse(ID) ==> ID
LemIST 2009-04-21
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 dunchange 的回复:]
ID是 int类型的
[/Quote]
用ID.ToString()
SqlCommand cmd = new SqlCommand("Update dbo.guestInfo set Reply = '"+ this.txtContent.Text+"' where ID = "+ ID.ToString() +"", conn);
gjw_8888 2009-04-21
  • 打赏
  • 举报
回复

string sql="Update dbo.guestInfo set Reply ='"+ this.txtContent.Text+"' where ID = "+ ID.tostring()

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧