首先将数据放入dataset:
SqlConnection con=new SqlConnection("Data Source=servername;Initial Catalog=databasename;User ID=sa;Password=pass");
string strText="select * from table";
DataSet ds=new DataSet();
SqlDataAdapter da=new SqlDataAdapter(strText,con);
con.Open();
da.Fill(ds);
然后就用datagrid或者其他的控件连接。
DataGrid1.DataSource=ds.tables[0];
SqlConnection con=new SqlConnection("Data Source=servername;Initial Catalog=databasename;User ID=sa;Password=pass");
string strText="select * from table";
DataSet ds=new DataSet();
SqlDataAdapter da=new SqlDataAdapter(strText,con);
con.Open();
da.Fill(ds);
然后就用datagrid或者其他的控件连接。
DataGrid1.DataSource=ds.tables[0];
ms-help://MS.VSCC/MS.MSDNVS.2052/cpguide/html/cpconcreatingusingdataviews.htm
其实,看帮助满有用的。
得到DataSet或者DataView之后绑定就可以了
DataGrid1.DataSource=DataSet;// DataGrid1.DataSource=DataView;
DataGrid1.DataBind();