谁帮我看看啊,这个老是返回值为-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(); } }
- 9 回答
- 0 关注
- 714 浏览
添加回答
举报
0/150
提交
取消