| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1469 人关注过本帖
标题:[求助]登入问题
只看楼主 加入收藏
coolfaith
Rank: 1
等 级:新手上路
帖 子:194
专家分:0
注 册:2006-4-25
收藏
 问题点数:0 回复次数:22 
[求助]登入问题
小弟做一个登入界面,登入成功后运行另一个窗体,不成功则停留在这个窗体,现在做到这样,

SqlConnection thisConnection=new SqlConnection(@"Data Source=(local);Integrated Security=SSPI;"+"Initial Catalog=student");
thisConnection.Open();
SqlCommand cmd=new SqlCommand("select Count(*) from userpass where userid='"+this.TextBox1.Text+"' and Password='"+this.TextBox2.Text+"'",thisConnection);
int count=Convert.ToInt32(cmd.ExecuteScalar());


thisConnection.Close();


中间应该添加什么啊
高手请指教
搜索更多相关主题的帖子: 登入 
2006-08-03 11:56
marer
Rank: 2
等 级:新手上路
威 望:3
帖 子:928
专家分:0
注 册:2005-7-18
收藏
得分:0 
//主函数
static void Main()
{
//显示登陆窗体
frmLogin login=new frmLogin();
login.ShowDialog();
//如果登陆成功,显示主窗体
if(frmLogin.IsLogin==true)
{
Application.Run(new MainForm());
}
}

public class 人生历程 extends Thread{public void run(){while(true){努力,努力,再努力!!;Thread.sleep(0);}}}
2006-08-03 12:04
coolfaith
Rank: 1
等 级:新手上路
帖 子:194
专家分:0
注 册:2006-4-25
收藏
得分:0 
我的SQL连接是在BOTTON-CLICK事件上的啊,运行后如果想实现那个功能,不是要在打开数据库和关闭数据库之间写选择代码吗?

2006-08-03 12:14
小海龟
Rank: 6Rank: 6
等 级:贵宾
威 望:23
帖 子:1068
专家分:4
注 册:2006-8-1
收藏
得分:0 
在button_click的事件中写如下代码:
int count;
SqlConnection con=new SqlConnection("server=.;database=student;uid=sa;pwd=");
con.Open();
SqlCommand com=new SqlCommand("select Count(*) from userpass where userid='"+this.TextBox1.Text+"' and Password='"+this.TextBox2.Text+"'"",con);
count=com.ExecuteNonQuery();
if(count>0)
{
MessageBox.show("登陆成功");
}
else
{
MessageBox.show("登陆失败");

}

[bc09] 犯强汉者,虽远比诛!
2006-08-03 12:22
coolfaith
Rank: 1
等 级:新手上路
帖 子:194
专家分:0
注 册:2006-4-25
收藏
得分:0 
我登入成功后想跳到新的窗体
private void button2_Click(object sender, System.EventArgs e)
{

SqlConnection thisConnection=new SqlConnection(@"Data Source=(local);Integrated Security=SSPI;"+"Initial Catalog=student");
thisConnection.Open();
SqlCommand cmd=new SqlCommand("select Count(*) from userpass where userid='"+this.TextBox1.Text+"' and Password='"+this.TextBox2.Text+"'",thisConnection);
int count=Convert.ToInt32(cmd.ExecuteScalar());
if(count>0)
{
MessageBox.Show("登陆成功");
Application.RunDialog(new MainForm());

}
else
{
MessageBox.Show("登陆失败");
thisConnection.Close();
}
}


下划线的那句有问题啊,怎么改啊

2006-08-03 12:38
coolfaith
Rank: 1
等 级:新手上路
帖 子:194
专家分:0
注 册:2006-4-25
收藏
得分:0 
还有啊,为什么这样子登入,在数据库中有用户名和密码的输入都成功,而只有用户名空密码的登入就不会成功啊,那游客就不能登入了啊,怎么改啊

2006-08-03 12:40
coolfaith
Rank: 1
等 级:新手上路
帖 子:194
专家分:0
注 册:2006-4-25
收藏
得分:0 
输入的密码怎么让它在登入框上变*****号啊

2006-08-03 12:42
coolfaith
Rank: 1
等 级:新手上路
帖 子:194
专家分:0
注 册:2006-4-25
收藏
得分:0 

没人帮助我一下啊


2006-08-03 16:09
chenjin145
Rank: 1
等 级:禁止访问
帖 子:3922
专家分:0
注 册:2006-7-12
收藏
得分:0 
textbox.textmode=password

[url=javascript:alert(1);] [div]fdgfdgfdg\" on\"[/div] [/url]
2006-08-03 16:32
coolfaith
Rank: 1
等 级:新手上路
帖 子:194
专家分:0
注 册:2006-4-25
收藏
得分:0 
一会我试试看,谢谢

2006-08-03 17:29
快速回复:[求助]登入问题
数据加载中...
 
   



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

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