我数据添加成功了,但cmd.ExecuteNonQuery() =-1,请问谁遇到过这种情况,怎么回事
protectedboolExecuteNonQuery(Stringsql,CommandTypecmdtype,SqlTransactiontrans,paramsS...
protected bool ExecuteNonQuery(String sql, CommandType cmdtype, SqlTransaction trans, params SqlParameter[] parms)
{
bool result = false;
SqlCommand cmd = null;
if (trans != null)
cmd = PreparedCommand(sql, trans.Connection, cmdtype, trans, parms);
else
cmd = PreparedCommand(sql, con, cmdtype, null, parms);
try
{
string a = cmd.ExecuteNonQuery().ToString();
if (cmd.ExecuteNonQuery() > 0)
{
result = true;
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
return result;
}
意思就是增删改成功与否永远都返回false请问怎么办 展开
{
bool result = false;
SqlCommand cmd = null;
if (trans != null)
cmd = PreparedCommand(sql, trans.Connection, cmdtype, trans, parms);
else
cmd = PreparedCommand(sql, con, cmdtype, null, parms);
try
{
string a = cmd.ExecuteNonQuery().ToString();
if (cmd.ExecuteNonQuery() > 0)
{
result = true;
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
return result;
}
意思就是增删改成功与否永远都返回false请问怎么办 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询