コード例 #1
0
        private void button1_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_search f2 = new Form_search();
                    f2.s_IS = textBox1.Text.ToString();
                    this.Hide();
                    f2.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); }
           
        }
コード例 #2
0
        private void button1_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_search f2 = new Form_search();
                    f2.s_IS = textBox1.Text.ToString();
                    this.Hide();
                    f2.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)
        {
            Form_search f2 = new Form_search();

            f2.s_IS = s_IA;
            this.Hide();
            f2.Show();
        }
コード例 #4
0
 private void button4_Click(object sender, EventArgs e)
 {
     Form_search f2 = new Form_search();
     f2.s_IS = s_IA;
     this.Hide();
     f2.Show();
 }