注册 登录
编程论坛 C语言论坛

表中是否有重复值

kent73 发布于 2021-09-15 11:56, 1451 次点击
正在学习C中,请问下面这段话,哪里有问题,怎么获取的res值,不论是否有重复值,都是-1

string sql = "select count(Fbarcode) as fcount from  T_XBXX where Fbarcode='" + txtbac.Text + "'";            
int res = SQLSERVERUtil.ExecuteSQL(sql);

谢谢
2 回复
#2
kent732021-09-15 16:28
使用string sql = "select * from  T_XBXX where Fbarcode='" + txtbac.Text + "'";

不论是不是有数值,res也是-1
#3
自由而无用2021-09-15 17:06
review the source code of the method "Class.ExecuteSQL(string)"(.net)

good luck!
#4
kent732021-09-16 08:12
回复 3楼 自由而无用
谢谢回复,正在学习中,麻烦了,谢谢
class SQLSERVERUtil
{
省略
}
//能按条件,删除成功
string sql = "delete from  T_XBXX where Fbarcode='" + txtbac.Text + "'";            
int res = SQLSERVERUtil.ExecuteSQL(sql);

但是使用这句语句,res值都是-1
string sql = "select * from  T_XBXX where Fbarcode='" + txtbac.Text + "'";
int res = SQLSERVERUtil.ExecuteSQL(sql);
1