谁帮我看看啊,这个老是返回值为-1,一调试,就叫我重启vs什么问题啊,急求帮助!!
public int ValidateAdmin(string sql, string adminID,string adminPwd)
{
int i;
try
{
this.openCon();
this.cmd = new SqlCommand(sql, this.con);
this.cmd.CommandType = CommandType.StoredProcedure;
SqlParameter[] pars = new SqlParameter[] {
new SqlParameter("@AdminID", SqlDbType.VarChar,50),
new SqlParameter("@AdminPwd", SqlDbType.VarChar,50)
};
pars[0].Value = adminID;
pars[1].Value = adminPwd;
foreach (SqlParameter parameter in pars)
{
this.cmd.Parameters.Add(parameter);
}
i = (int)this.cmd.ExecuteScalar();
}
catch
{
i = -1;
}
finally
{
this.closeCon();
}
return i;
}
public void openCon()
{
if (this.con == null)
{
this.con = new SqlConnection(this.strCon);
}
if (this.con.State.Equals(ConnectionState.Closed))
{
this.con.Open();
}
}
尚方宝剑之说
千万里不及你
慕姐8265434
莫回无
跃然一笑
陪伴而非守候
繁花如伊
相关分类