注册 登录
编程论坛 ASP.NET技术论坛

怎么查到的信息显示在GridView控件

qidao308 发布于 2016-03-19 20:44, 4672 次点击
跪求中,用SQL语句查询SQL server数据库tb_files表里的信息,然后把查到的信息显示在GridView控件

只有本站会员才能查看附件,请 登录
1 回复
#2
qidao3082016-03-19 20:45
        string sql = "select * from teacher where Teaid LIKE '% " + TextBox1.Text + " %'";
        SqlConnection con = new SqlConnection();
        con.ConnectionString = ConfigurationManager.ConnectionStrings["teacher"].ConnectionString;
        SqlCommand cmd = new SqlCommand(sql, con);
        SqlDataAdapter dp = new SqlDataAdapter();
        DataSet ds = new DataSet();
        dp.Fill(ds);
        GridView2.DataSource = ds.Tables[0];
1