连接数据库,获得表中数据
System.Data.SqlClient.SqlDataAdapter d = new System.Data.SqlClient.SqlDataAdapter("select * from table","data source=192.168.11.110;user id=sa;password=sa;initial catalog=regfair");
DataSet ds= new DataSet();
d.Fill(ds,"forieger");
在页面上添加一个DataGrid,点击  属性生成器-》列
添加绑定列,并将该绑定列的数据字段设为表table中的一个字段名
将表中数据绑定到DataGrid
DataGrid1.DataSource= ds.Tables[0].DefaultView;
DataGrid1.DataBind();

解决方案 »

  1.   

    去QuickStart里去看DataGrid!
    自己可以解决的问题,应该尝试自己解决。这样才会有提高。
      

  2.   

    我想是这样
        建立一个server
        一个client 
        从 client 输入 SQL 字符串 通过 server 执行一个方法
        返回一个 数据集
        然后在 client 显示到 grid 中
        那位帮帮忙??!!!