我非常确定这是我的数据绑定的问题,但我不确定问题到底是什么。使用mysql,我可以在数据集中显示行,但在执行绑定后,数据视图中不会显示任何行。
conn = new MySqlConnection("server=localhost;database=mydb;uid=user;password=pass");
conn.Open();
grid = new DataGridView();
grid.Dock = DockStyle.Fill;
ds = new DataSet();
adpt = new MySqlDataAdapter("select * from test limit 6;", conn);
adpt.Fill(ds);
Debug.WriteLine("data set rows found " + ds.Tables[0].Rows.Count);
binding = new BindingSource();
binding.DataSource = ds;
grid.DataSource = binding;
Debug.WriteLine("data grid rows found " + grid.Rows.Count);
conn.Close();
Controls.Add(grid);这个的调试打印输出是6和0。有人知道我的问题出在哪里吗?
提前感谢!
发布于 2012-05-08 00:18:36
只管去做
grid.DataSource = ds.Tables[0];发布于 2012-05-08 00:21:06
或者..。如果要使用BindingSource (例如用于过滤),请设置
binding.DataSource = ds.Tables[0];https://stackoverflow.com/questions/10485412
复制相似问题