日期:2014-05-17 浏览次数:20588 次
if (BLL.Users.CheckUser("张三", "123").Read())
{
Response.Write("登录成功!");
}
else
{
Response.Write("登录失败!");
}
/// <summary>
/// 是否存在该记录
/// </summary>
public static SqlDataReader CheckUser(string uName, string uPwd)
{
return SQLServerDAL.Users.CheckUser(uName, uPwd);
}
public static SqlDataReader ExecuteReader(CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)//设置断点看过N次了,commandParameters有值
{
SqlCommand cmd = new SqlCommand();
SqlConnection conn = new SqlConnection(ConnectionStringLocalTransaction);
// we use a try/catch here because if the method throws an exception we want to
// close the connection throw code, because no datareader will exist, hence the
// commandBehaviour.CloseConnection will not work
try
{
PrepareCommand(cmd, conn, null, cmdType, cmdText, commandParameters);
SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection);//断点到这里一看rdr=null;!!直接跳到Catch了!!!
cmd.Parameters.Clear();
return rdr;
}
catch
{
conn.Close();
throw;
}
}