| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1114 人关注过本帖
标题:这段代码其中有一些不太明白??是判断不能重复注册的...
只看楼主 加入收藏
爱颖无间道
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2008-3-30
收藏
 问题点数:0 回复次数:5 
这段代码其中有一些不太明白??是判断不能重复注册的...
string sql = "select count(*) from yanzheng where vdengluname='" + textBox1.Text + "'";//不明白,查询的目的是什么??

SqlConnection connection = new SqlConnection("Data Source=05608A0429C64E1\\123;Initial Catalog=jimmy;User ID=guchao;Password=jimmy");//明白
SqlCommand command = new SqlCommand(sql, connection);

command.Connection.Open();
int n = Convert.ToInt32(command.ExecuteReader ());//什么意思????//command.ExecuteReader ()不明白
command.Connection.Close();
if (n > 0) //n<0代表什么呢?
{
MessageBox.Show("该用户已经存在,请重新输入!");
this.textBox1.Text = "";
textBox1.Select();
}

麻烦解释一下 ,加注释的地方
搜索更多相关主题的帖子: command 代码 jimmy Connection 
2008-04-12 17:50
ioriliao
Rank: 7Rank: 7Rank: 7
来 自:广东
等 级:贵宾
威 望:32
帖 子:2829
专家分:647
注 册:2006-11-30
收藏
得分:0 
string sql = "select count(*) from yanzheng where vdengluname='" + textBox1.Text + "'";//查找从textbox1.text输入的用户名
int n = Convert.ToInt32(command.ExecuteReader ());//执行sql并返回行数.
if (n > 0) //如果n>0,刚证明用户存在么.

/images/2011/147787/2011051411021524.jpg" border="0" />
2008-04-12 18:51
爱颖无间道
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2008-3-30
收藏
得分:0 
那如果这样的话 SqlDataReader reader = command.ExecuteReader();
int n = Convert.ToInt32(reader[0].ToString());和

int n = Convert.ToInt32(command.ExecuteReader ());得到的效果一样吗?
2008-04-12 22:29
peterandy
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2008-3-31
收藏
得分:0 
?不明白
2008-04-13 12:00
xf12839356
Rank: 1
等 级:新手上路
帖 子:89
专家分:0
注 册:2007-11-6
收藏
得分:0 
自己试下不就明白了么
2008-04-13 16:48
梦心
Rank: 4
来 自:福建平和
等 级:贵宾
威 望:13
帖 子:1910
专家分:0
注 册:2007-5-11
收藏
得分:0 
int n = Convert.ToInt32(command.ExecuteReader ());
执行sql并返回行数,然后转换为INT型!!!
楼主......看书.....多想想.....

我清高和我骄傲的倔强,在风中大声的唱:我不听,我不听~~做我自己最特别,呼呼~~啦啦~~~
我的博客园地址: [url]http://[/url]
2008-04-13 19:13
快速回复:这段代码其中有一些不太明白??是判断不能重复注册的...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015300 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved