string str="select * from 學生信息 where 學號 like '%"+this.textBox9.Text.Trim()+"%'";DataTable dt=dataSet11.Tables [0];dataSet11.學生信息.Clear();dataGrid1.DataSource =dt;怎么把查詢后的數據顯示在dataGrid1上呢?能不能幫我修改上面這一段代碼?我都是采用控件寫的
3 回答

HUX布斯
TA貢獻1876條經驗 獲得超6個贊
SqlConnection con = new SqlConnection();
//con.ConnectionString = "Data Source=IT14;Initial Catalog=GIS_FX;User ID=sa;Password=it2";
con.ConnectionString = "Data Source=IT14;database=GIS_FX;User ID=sa;Password=it2";
con.Open();
SqlCommand cmd = new SqlCommand(/*SQL語句*/);
SqlDataReader dr = cmd.ExecuteReader();
GridView1.DataSource = dr;
GridView1.DataBind();
添加回答
舉報
0/150
提交
取消