先引用:using System.Data.SqlClient;
[CODE]string connstring = "serve=数据库名字;database=数据库名;uid=数据库的用户名;pwd=数据库的密码;";
string sqlstr = "select * from table1";
SqlConnection myconn = new SqlConnection(connstring);
DataSet ds = null;
SqlDataAdapter da = new SqlDataAdapter(sqlstr, myconn);
ds = new DataSet();
da.Fill(ds);
this.GridView1.DataSource = ds; //綁定數據
this.GridView1.DataBind();[/CODE]