类库代码如下:
/// 把SqlDataReader对象中的数据读出到List中
/// 转换后的列表对象
private List GetUse(SqlDataReader reader)
{
List uselist = new List();
while (reader.Read())
{
use.UName = reader["UName"].ToString();
use.Password = reader["Password"].ToString();
uselist.Add(use);
}
reader.Close();
return uselist;
}
/// 根据给定的查询条件,返回考生对象列表
public List GetuseBySqlStr(string strWhere)
{
string sql = "select * from UserInfo where 1=1 " + strWhere;
using (SqlDataReader dr = SqlDatabase.ExecuteReader(CommandType.Text, sql))
{
return GetUse(dr);
}
}
/// 根据给定的条件判断是否存在记录
public bool Existbystr(string str)
{
string sql = "select * from UserInfo where 1=1 " + str;
if (SqlDatabase.ExecuteScalar(CommandType.Text, sql) != null)
return true;
else
return false;
}
.aspx.cs后台部分代码如下:
if (use.Existbystr("and [UName]='" + txtName.Text + "'"))
{判断输入的用户名正确之后
---------这里应该怎么引用类库里的函数,来实现通过登录名查询数据库中对应的密码,判断是否和密码框(txtpassword)相同。
}
急求补充if条件语句里的代码