コード例 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            string        str1 = comboBox2.Text;
            string        str2 = textBox1.Text;
            string        str3 = textBox2.Text;
            SqlConnection cn   = new SqlConnection();

            cn.ConnectionString = "server=.;database=ss;uid=sa;pwd=chq;";

            string sql = "select * from teacher;";

            cn.Open();
            SqlCommand cmd = new SqlCommand();

            cmd.CommandText = sql;
            cmd.Connection  = cn;
            SqlDataReader sdr = cmd.ExecuteReader();

            while (sdr.Read())
            {
                if (sdr.HasRows != false)
                {
                    教师评分界面 form = new 教师评分界面();
                    form.Show();
                    this.Visible = false;
                }
                else
                {
                    MessageBox.Show("密码错误,请重新输入!!");
                }
            }
            cn.Close();
        }
コード例 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string str1 = comboBox2.Text;
            string str2 = textBox1.Text;
            string str3 = textBox2.Text;
            SqlConnection cn = new SqlConnection();
            cn.ConnectionString = "server=.;database=ss;uid=sa;pwd=chq;";

            string sql = "select * from teacher;";

            cn.Open();
            SqlCommand cmd = new SqlCommand();

            cmd.CommandText = sql;
            cmd.Connection = cn;
            SqlDataReader sdr = cmd.ExecuteReader();
            while (sdr.Read())
            {

                if (sdr.HasRows != false)
                {
                    教师评分界面 form = new 教师评分界面();
                    form.Show();
                    this.Visible = false;

                }
                else
                    MessageBox.Show("密码错误,请重新输入!!");

            }
            cn.Close();
        }