if (textBox_user.Text == "")
{
MessageBox.Show("用户名为空!");
textBox_user.Focus();
return;
}
if (textBox_pwd.Text == "")
{
MessageBox.Show("密码不能为空!");
textBox_pwd.Focus();
return;
}
SqlConnection cmd12 = new SqlConnection("server=127.0.0.1;uid=sa;pwd=123;database=REMIS");
string str12 = "select uid,pwd from user where uid='" +textBox_user.Text+"'and pwd='" +textBox_pwd.Text+"'";
cmd12.Open();
SqlCommand com = new SqlCommand(str12,cmd12); ;
SqlDataReader dr = com.ExecuteReader();
if (dr.Read())
{
this.Close();
new ALL().Show();
}
else
{
MessageBox.Show("登录错误,请重新输入!");
textBox_user.Clear();
textBox_pwd.Clear();
cmd12.Close();
}
{
MessageBox.Show("用户名为空!");
textBox_user.Focus();
return;
}
if (textBox_pwd.Text == "")
{
MessageBox.Show("密码不能为空!");
textBox_pwd.Focus();
return;
}
SqlConnection cmd12 = new SqlConnection("server=127.0.0.1;uid=sa;pwd=123;database=REMIS");
string str12 = "select uid,pwd from user where uid='" +textBox_user.Text+"'and pwd='" +textBox_pwd.Text+"'";
cmd12.Open();
SqlCommand com = new SqlCommand(str12,cmd12); ;
SqlDataReader dr = com.ExecuteReader();
if (dr.Read())
{
this.Close();
new ALL().Show();
}
else
{
MessageBox.Show("登录错误,请重新输入!");
textBox_user.Clear();
textBox_pwd.Clear();
cmd12.Close();
}
解决方案 »
- 编译器错误消息: CS1010: 常量中有换行符
- 请教ManualResetEvent.WaitOne在win2003下导致线程无法执行问题。
- 请教如何使用XPath对xml进行相应的查询
- 求助,C#如何做出像迅雷7或迅雷看看Preview版那样的皮肤、动态效果
- 谁帮我把Oracle的查询语句转换成标准的SQL语句啊?
- 如何取消操作
- 高分求助!文件解压安全问题!
- 简单问题送分:怎样在treeview中添加checkbox控件?
- Label5.Text = GridView1.DataKeys[GridView1.SelectedIndex].Value.ToString()出错了
- 大家都什么控件做选项卡啊。
- e.KeyCode == Keys.Enter如何排除弹出的消息框
- 关于存在外键约束的表的提交问题
cmd12.Open();
SqlCommand com = new SqlCommand(str12,cmd12); ;
int sum=Convert.ToInt32(com.ExecuteScalar());
if (sum>0)
{
//成功
new ALL().Show();
}
else
{
MessageBox.Show("登录错误,请重新输入!");
textBox_user.Clear();
textBox_pwd.Clear();
cmd12.Close();
}
楼主对象实例命名有点问题,取的名字不好理解
dr.Read()
if (dr.HasRows) 这个改下试试
{
this.Close();
new ALL().Show();
}
else
{
MessageBox.Show("登录错误,请重新输入!");
textBox_user.Clear();
textBox_pwd.Clear();
cmd12.Close();
}
cmd12.Open();
SqlCommand com = new SqlCommand(str12,cmd12); ;
SqlDataReader dr = new SqlDataReader(com);
// 数据的取得
DataSet ds = new DataSet();
dr.Fill(ds);
DateTable dtlResult = ds.Tables[0];
if (dtSearch.Rows.Count > 0)
{
//成功
new ALL().Show();
}
else
{
MessageBox.Show("登录错误,请重新输入!");
textBox_user.Clear();
textBox_pwd.Clear();
}
cmd12.Close();