看下面的例子:string selectstr="select * from yourtable where restrain=1 order by ID DESC"; SqlConnection myConnection=new SqlConnection("server=localhost;uid=sa;pwd=; database=yourdatabase");
SqlDataAdapter myAdapter=
new SqlDataAdapter(selectstr,myConnection);
DataSet ds=
new DataSet(); myAdapter.Fill(ds,"yourtable"); myDataGrid.DataSource=ds.Tables["yourtable"].DefaultView;
myDataGrid.DataBind();
SqlDataAdapter myAdapter=
new SqlDataAdapter(selectstr,myConnection);
DataSet ds=
new DataSet(); myAdapter.Fill(ds,"yourtable"); myDataGrid.DataSource=ds.Tables["yourtable"].DefaultView;
myDataGrid.DataBind();
SqlConnection myConnection = new SqlConnection("server=(local);uid=sa;pwd=;database=TaxWebGis;Trusted_Connection=yes");
sSQL=(String)Session["sql"];
title=Request.QueryString["title"];
Label1.Text = title;
SqlDataAdapter myCommand = new SqlDataAdapter(sSQL, myConnection);
DataSet ds1 = new DataSet();
myCommand.Fill(ds1,"DJ_NSRXX"); DataGrid1.DataSource = ds1.Tables["DJ_NSRXX"].DefaultView;
DataGrid1.DataBind();
好吗?????