求高手帮忙指点指点(本人菜鸟)
数据库设计.zip
(125.52 KB)
压缩包中有我关于此数据库所要达到的功能的表述,也有我自己编写的数据库大概轮廓。语句都没有错误!但是就是执行不下去!寻高手指点!
private void button1_Click(object sender, EventArgs e) { Form2 form2_01 = new Form2(); OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "/" + "DB.mdb"); aConnection.Open();///打开数据库 string SQLString = "select * from user where name=" + textBox1.Text.Trim() + " and password="+textBox2.Text.Trim ();///设置sql 查询语句 OleDbDataAdapter myadapter = new OleDbDataAdapter(SQLString, aConnection); ///创建适配器,执行sql 查询 DataSet ds = new DataSet(); ///建立数据集 myadapter.Fill(ds); ///将查询结果加入 ds 中 if (ds.Tables[0].Rows.Count > 0) ///判断用名密码是否正确 { OleDbDataAdapter qx_adapter = new OleDbDataAdapter("select qx from user where name=" + textBox1.Text.Trim() , aConnection); DataSet ds_qx = new DataSet(); qx_adapter.Fill(ds_qx); qx = Convert.ToInt32(ds_qx.Tables[0].Rows[0]["qx"]); this.Hide(); form2_01 form2 = new form2_01(qx); form2.Show(); } else { ///MessageBox.Show("你按了确定"); MessageBox.Show("对不起,请输入正确的用户名和密码"); } aConnection.Close();///关闭数据库连接(必须) }在你的form2_01里,重构一下构造方法
private int i = 0; public form2_01(int qx) { InitializeComponent(); this.i = qx; }然后在formload事件里,执行你的权限控制