Ejemplo n.º 1
0
        private void skinButton1_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new Opreate().conn();

            conn.Open();
            string strCmd;

            if (textBox1.Text.Equals("*"))
            {
                strCmd = "select * from Teacher_teaching";
            }
            else
            {
                strCmd = "select * from Teacher_teaching where " + skinComboBox1.Text + " = '" + textBox1.Text + " '";
            }

            //dtGrdViewSearch.Rows.Clear();

            SqlDataAdapter myDataAdapter;
            DataSet        myDataSet = new DataSet();

            myDataAdapter = new SqlDataAdapter(strCmd, conn);
            myDataAdapter.Fill(myDataSet, "Teacher_teaching");
            skinDataGridView1.DataSource = myDataSet.Tables["Teacher_teaching"];

            conn.Close();
        }
Ejemplo n.º 2
0
        private void skinButton7_Click(object sender, EventArgs e)
        {
            SqlConnection Conn = new Opreate().conn();//到sqlsever的连接

            Conn.Open();
            string        Sql  = "select top 1 * from teacher order by tno desc";
            SqlCommand    comm = new SqlCommand(Sql, Conn);                  //command对象
            SqlDataReader dr   = comm.ExecuteReader();                       //定义数据读取对象

            if (dr.Read())
            {
                skinTextBox1.Text  = (string)dr.GetValue(0);
                skinTextBox2.Text  = (string)dr.GetValue(1);
                skinComboBox1.Text = (string)dr.GetValue(2);
                skinComboBox2.Text = dr.GetValue(3).ToString();
            }
            Conn.Close();
        }