public void del(string m)
{
SqlConnection conn1=new SqlConnection();
conn1.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["aa"] ; string sql1="delete table aa where id="+m;
SqlCommand cmd1=new SqlCommand(sql1,conn1);
cmd1.CommandType=CommandType.Text;
cmd1.Connection.Open();
cmd1.ExecuteNonQuery();
conn1.Close();
}
我直接给m赋值的时候可以执行,但是我通过变量的时候就提示cmd1.ExecuteNonQuery(); 有错误
请帮我看一下是为什么呢?谢谢
{
SqlConnection conn1=new SqlConnection();
conn1.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["aa"] ; string sql1="delete table aa where id="+m;
SqlCommand cmd1=new SqlCommand(sql1,conn1);
cmd1.CommandType=CommandType.Text;
cmd1.Connection.Open();
cmd1.ExecuteNonQuery();
conn1.Close();
}
我直接给m赋值的时候可以执行,但是我通过变量的时候就提示cmd1.ExecuteNonQuery(); 有错误
请帮我看一下是为什么呢?谢谢
解决方案 »
- 调用MSSQL的存储过程出现问题了
- 我发的帖子怎么不停的刷新? 看这个,dataGridView终于能导出Excel 了!但又发现2个问题: 多导出一个Excel就多一个进程(进程不会自动关闭),超过570行数据就出错!
- Bs 程序多次点击按钮触发多次事件,数据重复录入问题
- 服务里是不是event不起作用
- 三个窗体之间的数据传递,在线等
- (来人领分! 没人回答!!!)C# web服务移植到OpenSUSE系统的mono环境下build报错问题!! 请大家帮帮忙~~ 谢谢啦!!
- 5CD的.net安装盘第一张丢了=。=,求个能下载的CD1
- 我要在.exe里面的Main()里面设置参数怎么设置,怎么调用呢
- 怎样历偏文件?
- 使用Xilium.CefGlue加载包含video标签的Html5页面,结果不能播放视频?
- 关于记录添加的问题,在线等,欢迎讨论!!!
- DateTime类型,鸡肋!今天把所有表结构的DateTime改成了string,这下轻松多了!
改为string sql1="delete table aa where [id]= '"+m + "'";
string sql1="delete table aa where id='"+m+"'";
string sql1="delete table aa where id="+"1";
这样不行?
string sql1="delete table aa where id="+m;8可能的,你确定public void del(string m)传近来的参数是数字?
string sql1="delete table aa where id="+m;
string sql1="delete table aa where id='"+m+"'";
原来的也没错啊
ID是什么型?