此采用的是三层架构,BLL,DAL,UI
怎么样才能判断用户名是否存在呢,以下是我初写的代码,发现有错,不知道怎么写,跪求大神
报错信息,Row不存在
怎么样才能获取数据库查询结果呢
Row=0的时候做插入数据
否则弹出对话框
protected void btn_Click(object sender, EventArgs e)
{
string user = txtuser.Text;
DataTable table = BLL.Mgr.exausers(user);
if (Row = 0)
{
Model.USER user = new Model.USER();
try
{
user.user = user.Text;
user.mail = user.Text;
BLL.Login.Saveuser(user);
Response.Write("<script>alert('添加成功!');</script>");
}
catch
{
Response.Write("<script>alert('添加失败!');</script>");
}
}
else
{
Response.Write("<script>alert('此用户名已存在');</script>");
}
}