示例#1
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                string        sConnectionString = "data source=cypress.csil.sfu.ca;" + "initial catalog=hga13354;" + "Trusted_Connection=yes;";
                SqlConnection objConn           = new SqlConnection(sConnectionString);
                objConn.Open();

                SqlCommand    cmd = new SqlCommand("select s_ID, s_pw from dbo.Student where s_ID= '" + textBox1.Text + "'  and s_pw= '" + textBox2.Text + "' ", objConn);
                SqlDataReader sdr = cmd.ExecuteReader();
                sdr.Read();

                if (sdr.HasRows)
                {
                    Form_report f3 = new Form_report();
                    f3.s_IA = textBox1.Text.ToString();
                    this.Hide();
                    f3.Show();
                    objConn.Close();
                    objConn.Dispose();
                }
                else
                {
                    MessageBox.Show("Incorrect Student ID or Password");
                    objConn.Close();
                    objConn.Dispose();
                }
                objConn.Close();
                objConn.Dispose();
            }
            catch (SqlException sqlEx) { MessageBox.Show("SQL Server Error Message:" + sqlEx.Message); }
        }
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                string sConnectionString = "data source=cypress.csil.sfu.ca;" + "initial catalog=hga13354;" + "Trusted_Connection=yes;";
                SqlConnection objConn = new SqlConnection(sConnectionString);
                objConn.Open();

                SqlCommand cmd = new SqlCommand("select s_ID, s_pw from dbo.Student where s_ID= '" + textBox1.Text + "'  and s_pw= '" + textBox2.Text + "' ", objConn);
                SqlDataReader sdr = cmd.ExecuteReader();
                sdr.Read();

                if (sdr.HasRows)
                { 
                    Form_report f3 = new Form_report();
                    f3.s_IA = textBox1.Text.ToString();
                    this.Hide();
                    f3.Show();
                    objConn.Close();
                    objConn.Dispose();
                }
                else
                {
                    MessageBox.Show("Incorrect Student ID or Password");
                    objConn.Close();
                    objConn.Dispose();
                }
                objConn.Close();
                objConn.Dispose();
            }
            catch (SqlException sqlEx) { MessageBox.Show("SQL Server Error Message:" + sqlEx.Message); }
           
        }
示例#3
0
        private void button4_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Are you sure?");
            Form_report f3 = new Form_report();

            f3.s_IA = s_IS;
            this.Hide();
            f3.Show();
        }
 private void button4_Click(object sender, EventArgs e)
 {
     MessageBox.Show("Are you sure?");
     Form_report f3 = new Form_report();
     f3.s_IA = s_IS;
     this.Hide();
     f3.Show();
 }