string connectionString = "server=服务器ip;database=数据库;uid=用户;pwd=密码";String sqlstr="select * from 表"sqldataAdapter = new SqlDataAdapter(sqlstr, SqlConnection(connectionString));
sqldataAdapter.Fill(ds);datagridview1.datasource=ds;这样就了~
SqlCommand com = dc.GetCommand("select * from lessoninfo");
SqlDataReader dr = com.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(dr);
this.dataGridView1.DataSource = dt;
winform里的不是太清楚,太久没用WEB里是这么用的加入从数据库查询出来的数据时存放在一个datatable里叫做dtdatagridview 名叫 datagridview1 datagridview1.source = dt;datagridview1.bind();