文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>c#判断用户是否存在

c#判断用户是否存在

时间:2008-08-07  来源:*^cherish^*


string sql = string.Format("select count(*) from huiyuan where name='{0}'", name1.Text);
SqlConnection cnn = new SqlConnection(sqlconn);
SqlCommand cmd = new SqlCommand(sql, cnn);
cnn.Open();
int a = (int)cmd.ExecuteScalar();//返回一个值,看看有没有
if (a == 0)
{
//插入的代码
}
else
{
//用户已存在
}
cnn.Close();
随手写的..没运行过
另外name1.text就是string型的 不用再ToString()
本贴来自ZDNetChina中文社区 http://bbs.zdnet.com.cn ,本贴地址:http://bbs.zdnet.com.cn/viewthread.php?tid=555412
   
相关阅读 更多 +
排行榜 更多 +
变形金刚前线下载中文版安装

变形金刚前线下载中文版安装

策略塔防 下载
巴巴利亚战争手游下载

巴巴利亚战争手游下载

休闲益智 下载
植物大战僵尸肉鸽版下载

植物大战僵尸肉鸽版下载

策略塔防 下载