- 博客(0)
- 资源 (2)
- 收藏
- 关注
图书管理系统C#开发
namespace 图书管理系统
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public static bool a = false;
private void button1_Click(object sender, EventArgs e)
{
//----------------------------------------------------------------
string str = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=books.mdb";
OleDbConnection conn = new OleDbConnection(str);
OleDbCommand cmd = new OleDbCommand();
cmd.Connection = conn;
string str2 =@"select * from admin where 用户名='" + this.textBox1.Text + "' and 密码='" + this.textBox2.Text + "'";
OleDbDataAdapter ole = new OleDbDataAdapter(str2, conn);
DataSet ds = new DataSet();
try
{
ole.Fill(ds,"admin");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
int h = ds.Tables[0].Rows.Count;// 返回表中行的数目
if (h == 0)
{
MessageBox.Show("用户名或密码错误,请重新输入");
textBox1.Text = this.textBox2.Text = "";
textBox1.Focus();
return;
}
else
{
a = true;
this.Close();
}
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
2011-07-06
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人