给个例子你,不用多说,一看就明白:string strcon="data source=server1;initial catalog=db1;user id=user1;packet size=4096"
SqlConnection con=new SqlConnection(strcon);
con.Open();
SqlCommand mycommand=new SqlCommand();
SqlDataAdapter mydatapter=new SqlDataAdapter();
DataSet myset=new DataSet();
mycommand.CommandText="select * from newpost order by postid desc";
mycommand.Connection=con;
mydatapter.SelectCommand=mycommand;

mydatapter.Fill(myset,"newpost");DataGrid1.DataSource=myset.Tables[0].DefaultView;
DataGrid1.DataBind();con.Close();