当前位置:编程学习 > C#/ASP.NET >>

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

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

说我输入的字符串格式不正确,请帮忙啊 --------------------编程问答-------------------- int.Parse(ID) ==> ID --------------------编程问答-------------------- SqlCommand cmd = new SqlCommand("Update dbo.guestInfo set Reply = '"+ this.txtContent.Text+"' where ID = "+ ID.ToString() +"", conn); 


ID是什么类型的?
--------------------编程问答-------------------- ID是 int类型的 --------------------编程问答-------------------- 不对啊会提示新的问题啊 --------------------编程问答--------------------

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

--------------------编程问答--------------------

string sql="Update dbo.guestInfo set Reply ='"+ this.txtContent.Text+"' where ID = "+ ID.tostring()
--------------------编程问答--------------------
引用 3 楼 dunchange 的回复:
ID是 int类型的

用ID.ToString()
SqlCommand cmd = new SqlCommand("Update dbo.guestInfo set Reply = '"+ this.txtContent.Text+"' where ID = "+ ID.ToString() +"", conn); 
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,