using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace 宾馆客房管理系统
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (IsUserIdentify() == true)
{
Form2 form1 = new Form2();
form1.Show();
this.Visible = false;
}
else
{
MessageBox.Show("用户名或密码错误");
}
}
private bool IsUserIdentify()
{
SqlConnection Conn = new SqlConnection("Data Source=.;Initial Catalog=客房管理系统;Integrated Security=True");
Conn.Open();
string sql = "SELECT Name,PassWord FROM Admin WHERE Name='" + this.textBox1.Text + "'and PassWord='" + this.textBox2.Text + "'";
SqlCommand Cmd = new SqlCommand(sql, Conn);
SqlDataReader reader = Cmd.ExecuteReader();
if (reader.Read())
{
return true;
}
else
{
return false;
}
Conn.Close();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
大神帮忙,小弟不胜感激
2 个解决方案
#1
哪里异常,以及异常信息。尤其是stack trace
#2
调试啊,就这么几句话
#1
哪里异常,以及异常信息。尤其是stack trace
#2
调试啊,就这么几句话