具体信息,如题所述~~
有没有谁帮忙解答,给出解决代码或方案,最好是代码,谢谢了!!!
现给出代码如下:
这是登录按钮的:
if (this.textBox1.Text != "" && this.textBox2.Text != "")
{
string str = "select * from user_info";
DataBase db = new DataBase();
DataSet ds = db.select(str);
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
if (ds.Tables[0].Rows[i][0].Equals(this.textBox1.Text)&&ds.Tables[0].Rows[i][1].Equals(this.textBox2.Text))
{
login = true;
}
}
if (login == false)
{
MessageBox.Show("用户信息不存在");
}
有没有谁帮忙解答,给出解决代码或方案,最好是代码,谢谢了!!!
现给出代码如下:
这是登录按钮的:
if (this.textBox1.Text != "" && this.textBox2.Text != "")
{
string str = "select * from user_info";
DataBase db = new DataBase();
DataSet ds = db.select(str);
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
if (ds.Tables[0].Rows[i][0].Equals(this.textBox1.Text)&&ds.Tables[0].Rows[i][1].Equals(this.textBox2.Text))
{
login = true;
}
}
if (login == false)
{
MessageBox.Show("用户信息不存在");
}
解决方案 »
- chart 控件 框选图表。
- 急求winfrom高手 帮我处理一些问题
- 【在线等】C#下载功能出了问题,请指教!
- 菜鸟求教高手!急用
- 请问dateTimePicker1控件的用法?
- 高手帮忙看看我这段代码什么问题好吗?
- if(!PostBack)什么意思
- C# 能加载文件或程序集“AspNetPager, Version=7.2.0.0, Culture=neutral, PublicKeyToken=fb0a0
- 关于timer和计数器的性能
- 调试VS.net里的反汇编窗口,用的是什么汇编阿?
- 窗体属性statrposition
- 为什么拖到tableLayoutPanel里的其它控件都只能自动左上角对齐啊,能不能改变他的对齐方式?
DataBase db = new DataBase();
DataSet ds = db.select(str); 还没学过以上这种方法我只会用SqlConnection 的联接
我的解决方法是:(如果你用的是SQL数据库)
string str = "select * from user_info";
SqlConnection con=new SqlConnection("server=.;database=数据库名;uid=用户名;pwd=密码");
DataSet sd=new DataSet();
DataAdapter da=new DataAdapter(str,con);
da.Fill(sd);
得到结果集上面的就一样了
顺便请教一下:
我朋友开了一家网店!开了一段时间,可没有多少人去买!我对经商不懂!如果您有空,请帮忙提点建议!非常感谢!她的网址是:http://shop35772943.taobao.com 再次感谢!
{
if (ds.Tables[0].Rows[i][0].Equals(this.textBox1.Text)&&ds.Tables[0].Rows[i][1].Equals(this.textBox2.Text))
{
login = true;
} }
改為這樣就可以了,我試過了:
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
if (ds.Tables[0].Rows[i][0].ToString()==(this.textBox1.Text)&& ds.Tables[0].Rows[i][1].ToString()==(this.textBox2.Text))
{
login = true;
break; //不加這會有一個問題,最後一行返回不是true的話,那麼最後也會提示沒有些用戶存在
}}
另外做登录只要查询是否有该用户就行了 返回个SQL命令COUNT(*)!=0不就可以了么
+TextBox2.Text"'"+;
然后用一楼的DbCommand.ExecuteReader方法
判断返回的是不是为空就可以了..为空就是用户名不存在或是密码不正确~
ds.Tables[0].Rows[i][0].ToString().Trim().Equals();
{
string str = "select * from user_info where username='"+TextBox1.Text+"' and userpwd='"+TextBox2.Text+"'";
SqlConnection conn = new SqlConnection();
conn.Open();
SqlCommand cmd = new SqlCommand(str,conn);
string s = cmd.ExecuteNonQuery();
if (s == "1") {
login=true;
}
else
{
MessageBox.Show("用户信息不存在");
}
}
if (this.textBox1.Text != "" && this.textBox2.Text != "")
{
SqlConnection conn = new SqlConnection("SqlConnectionString");
SqlCommand com = new SqlCommand("SELECT pwd FROM user_info WHERE uid='" + this.textBox1.Text + "'", conn);
SqlDataReader reader = com.ExecuteReader();
while (reader.Read())
if (reader.GetSqlString[0] == this.textBox2.Text)
login = true;
}
{
SqlConnection conn = new SqlConnection("SqlConnectionString");
SqlCommand com = new SqlCommand("SELECT pwd FROM user_info WHERE uid='" + this.textBox1.Text + "'", conn);
SqlDataReader reader = com.ExecuteReader();
while (reader.Read())
if (reader.GetSqlString[0] == this.textBox2.Text)
login = true;
}
不过还是谢谢