日期:2014-05-19  浏览次数:20448 次

SQL菜鸟级的问题
string   str_sql   =   "delete   from   news   where   ID   =   ' "+Convert.ToInt32(txt_ID.Text.Trim())+ " ' ";
提示数据类型不匹配,我觉得匹配着呀
ID是ACCESS中的长整型

------解决方案--------------------
string str_sql = "delete from news where ID = " Convert.ToInt64(txt_ID.Text.Trim())+ " ' ";

------解决方案--------------------
string str_sql = "delete from news where ID = "+ Convert.ToInt64(txt_ID.Text.Trim);
------解决方案--------------------
你ID是整型, ' " " '这个是字符型了呀
------解决方案--------------------
liyanli2007()
正解啊
不用单引号的
------解决方案--------------------
学习...
------解决方案--------------------
string str_sql = "delete from news where ID = "+Convert.ToInt32(txt_ID.Text.Trim());

------解决方案--------------------
string str_sql = "delete from news where ID = "+ Convert.ToInt64(txt_ID.Text.Trim);
------解决方案--------------------
在Access里不加单引号,在SQL里int的可以加单引号
------解决方案--------------------
怎么不给我加分呀