VS2005中的Login控件怎么用啊?? VS2005中的Login控件拖出来后不知道怎么用~~我要让它验证数据库中的数据与输入的数据一样后才能登录,可不知道怎么这个控件怎么连到自己的数据库.请高手指点~~ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我们做过管理系统的课程设计,关于登陆验证的这个是通过了的,希望有用private void button1_Click(object sender, EventArgs e) { if (txt1.Text == "") { MessageBox.Show("请输入用户名", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (txt2.Text == "") { MessageBox.Show("请输入密码", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { SqlConnection cn = new SqlConnection(@"server=localhost; database=fantasy; uid=sa; pwd=sa");//连接数据库 cn.Open(); string sql = "select count(*) from passID where [用户名]='" + txt1.Text + "' and [密码]='" + txt2.Text + "'"; SqlCommand cm = new SqlCommand(sql, cn); int i = Convert.ToInt32(cm.ExecuteScalar());//将查询的结果返回一个值,如果有的话就说明用户名 密码正确 if (i > 0) { cm = new SqlCommand("select * from passID where [用户名]='" + txt1.Text + "'", cn);//查询得到用户名的信息 SqlDataReader sdr = cm.ExecuteReader(); sdr.Read(); cn.Close(); frmMain main = new frmMain(); main.ShowDialog(); //Class1.fomload = false; //Class1.fomload1 = false; this.Close(); } else { MessageBox.Show("用户名或密码错误!"); } } } } 不是的,vs2005的Login控件是一个整体的东西,不是单独按了button按钮去获取TextBox里的数据,然后检查数据库里的数据是否存在。不知道Login控件怎么才能获取到数据库里的东西~ 将图片导入到Excel中的问题 +=(delegate)的事件,怎样取消? 怎么获取文本框的值插入数据 For语句求解 dataGrid的二个问题,请帮忙解决 那位高手知道学习Visual studio.net(C#) 中图像处理得比较好的网站有那些 项目的运行问题,急急急!在线等!高分 可以善自对购买的商业软件做数据库接口吗 ? 程序没有错,为什么出错了? 急,换成vs2012后,出现报错,求救 连接到源文件“G:\MeettingPro\meetingview.aspx.designer.cs”的撤消管理器时出错 帐户问题MembershipUser.IsLockedOut解锁
{
if (txt1.Text == "")
{
MessageBox.Show("请输入用户名", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
if (txt2.Text == "")
{
MessageBox.Show("请输入密码", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
SqlConnection cn = new SqlConnection(@"server=localhost; database=fantasy; uid=sa; pwd=sa");//连接数据库
cn.Open();
string sql = "select count(*) from passID where [用户名]='" + txt1.Text + "' and [密码]='" + txt2.Text + "'";
SqlCommand cm = new SqlCommand(sql, cn);
int i = Convert.ToInt32(cm.ExecuteScalar());//将查询的结果返回一个值,如果有的话就说明用户名 密码正确
if (i > 0)
{
cm = new SqlCommand("select * from passID where [用户名]='" + txt1.Text + "'", cn);//查询得到用户名的信息
SqlDataReader sdr = cm.ExecuteReader();
sdr.Read();
cn.Close();
frmMain main = new frmMain();
main.ShowDialog();
//Class1.fomload = false;
//Class1.fomload1 = false;
this.Close();
}
else
{
MessageBox.Show("用户名或密码错误!");
}
}
}
}