dataset绑定到dataGridView

 今天在博客园上俺家了。以后要好好的学习,总结。今天先发个今天学到的东西

简单的吧dataset绑定到dataGridView的程序。因为现在在做一个windows mobile 6.0 的。里面好像没有 datagridview 只有 datagrid不知道用法是不是跟datagridview的用法一样。

现在 windows from上测试。

 1             SqlConnection con = new SqlConnection("server=192.168.1.32;user id=sa;pwd=guanke2802;database=seuic");
 2             string sql = string.Format("Select  * from biaoqian");
 3             SqlCommand myCommand = new SqlCommand(sql, con);
 4             SqlDataAdapter da = new SqlDataAdapter(myCommand);
 5             con.Open();
 6             DataSet ds = new DataSet();
 7             da.Fill(ds,"table");
 8             this.dataGridView1.DataSource = ds;
 9             this.dataGridView1.DataMember = "table";
10 
11             con.Close();
12             con.Dispose();

 

 

posted @ 2013-04-21 10:27  zengxw  阅读(362)  评论(0编辑  收藏  举报