是sql数据库吗?即使cid 是int类型的, 也可以写成where cid=‘"+ Program.Selid +"' ,
可以在两边放上单引号 ,可以在查询分析器中测试一下,
还有你这个语句可以打一个断点调试的时候看一下最终的sql 语句是什么 ,然后去查询分析器中测试一下。
可以删除的啊,是不是传入的参数不对,没有数据啊什么的
Program.Selid 不是int型吧,把它转成int型就可以了
删除数据一般是用主键索引作为条件的,你怎么还搞了俩条件呢?你先查查,select * from custom where cid=Program.Selid and cname = 'Program.SelName'是什么结果~!
string sql = "delete from custom where cid="+(int)Program.Selid +" and cname='"+ Program.Selname +"'";
string sql = "delete from custom where cid="+Convert.ToInt32(Program.Selid )+" and cname='"+ Program.Selname +"'";