当前位置: 代码迷 >> ASP.NET >> 如何验证用户名是否存在呢
  详细解决方案

如何验证用户名是否存在呢

热度:3766   发布时间:2013-02-26 00:00:00.0
怎么验证用户名是否存在呢?
想实现“检测用户名是否存在”这个功能。
用一个dataset,对userid进行了select。
弱弱的问下,该怎么使用dataset,怎样才能连接上,去查里面是否已经存在呢?

------解决方案--------------------------------------------------------
SqlConnection conn=new SqlConnection(strconn);
SqlCommand comm=new SqlCommand( "select * from users ",conn);
conn.Open();
SqlDataReader dr=comm.ExecuteReader();
if(dr.HasRows)
{
Response.Write( "存在 ");
}
else
{
Response.Write( "不存在 ");
}
conn.Close();
  相关解决方案