c#统计表中元素个数

zhimu 2006-12-21 09:07:00
统计user表中元素个数,用来判断用户名是否存在:
if语句中的判断条件应该怎么设置?请指点一下!
SqlConnection conn = new SqlConnection(strconn);
conn.Open();
string sql = "select count(*) from [user] where [uname]='"+TextBox1.Text.Trim()+"'";
SqlDataAdapter da = new SqlDataAdapter(sql,conn);
DataSet ds = new DataSet();
da.Fill(ds);
if (ds.Tables[0].Columns.Count > 0)
{
Label5.Text = "该用户名已经存在";
Label5.Visible = true;
}
if(ds.Tables[0].Columns.Count == 0)
{
Label5.Visible = false;
if (TextBox2.Text.Trim() == TextBox3.Text.Trim())
{
Response.Redirect("ok.aspx");
}
else
{
Label6.Text = "前后密码不一致";
Label6.Visible = true;
}
}
conn.Close();
...全文
265 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
YouTuBe 2006-12-21
  • 打赏
  • 举报
回复
沙发

2,127

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧