データベースDALラーニング(1)

9503 ワード

以前はウェブデザインに触れたことがないのでasp.Netは特に熟知しているわけではありません.
しかし、C#接続データベースは前学期に自分で管理システムを試み、成功した.(私がAcessを使っていることを認めたくない)
一部のコードは次のとおりです.
private void button1_Click(object sender, EventArgs e)

        {



            string strConnection = "Provider=Microsoft.ACE.OLEDB.12.0;";

            strConnection += @"Data Source=Database.accdb";

            OleDbConnection objConnection = new OleDbConnection(strConnection);

            if (comboBox1.Text == "     ")

            {

                objConnection.Open();

                OleDbCommand comm = new OleDbCommand("select * from       where User='" + textBox1.Text + "'AND Code='" + textBox2.Text + "'", objConnection);

                OleDbDataReader sda = comm.ExecuteReader();

                sda.Read();

                if (log(sda) == 1)

                {

                          f = new      ();

                    f.Show();

                }

            }

            if (comboBox1.Text == "     ")

            {

                objConnection.Open();

                OleDbCommand comm = new OleDbCommand("select * from       where User='" + textBox1.Text + "'AND Code='" + textBox2.Text + "'", objConnection);

                OleDbDataReader sda = comm.ExecuteReader();

                sda.Read();

                if (log(sda) == 1)

                {

                          f = new      (""+textBox1.Text+"");

                    f.Show();

                }

            }

            if (comboBox1.Text == "    ")

            {

                objConnection.Open();

                OleDbCommand comm = new OleDbCommand("select * from      where User='" + textBox1.Text + "'AND Code='" + textBox2.Text + "'", objConnection);

                OleDbDataReader sda = comm.ExecuteReader();

                sda.Read();

                if (log(sda) == 1)

                {

                         f = new     (""+textBox1.Text+"");

                    f.Show();

                }

            }

            if (comboBox1.Text == "    ")

            {

                objConnection.Open();

                OleDbCommand comm = new OleDbCommand("select * from      where User='" + textBox1.Text + "'AND Code='" + textBox2.Text + "'", objConnection);

                OleDbDataReader sda = comm.ExecuteReader();

                sda.Read();

                if (log(sda)==1)

                {

                         f = new     (""+textBox1.Text+"");

                    f.Show();

                }

            }

            if (comboBox1.Text == "   ")

            {

                objConnection.Open();

                OleDbCommand comm = new OleDbCommand("select * from     where User='" + textBox1.Text + "'AND Code='" + textBox2.Text + "'", objConnection);

                OleDbDataReader sda = comm.ExecuteReader();

                sda.Read();

                if (log(sda)==1)

                {

                        f = new    ();

                    f.Show();

                }

            }

        }

        public int log(OleDbDataReader test)

        {

            if (test.HasRows == true)

            {

                MessageBox.Show("    ");

                this.Hide();

                return 1;

            }

            else

            {

                MessageBox.Show("        ");

                return 0;

            }

        }

sql serverの異動は基本的にaccessと同じです.(未完待機)