将ResultSet绑定到DataGridView [J#] [英] Binding ResultSet to DataGridView [J#]
问题描述
大家好,
尝试将ResultSet绑定到DataGridView时遇到问题。尽管ResultSet已完全填充,但使用WriteLine进行测试,我无法在DataGridView中显示它。
我正在尝试的是:
reportQuery =
" SELECT * FROM Suppliers" ;CreateStatement();
ResultSet rs = stmt.executeQuery(reportQuery);
BindingSource bs = new BindingSource();
bs.set_DataSource(rs);
ResultGrid.set_DataSource(bs);
<我只是以空集结束。是否有可能以这种方式在DataGridView中显示数据?
任何帮助将不胜感激,
问候,迈克
尝试在DataGridView上将AutoGenerateColumns设置为true。
Luc
Hello everyone,
I have a problem when trying to bind a ResultSet to a DataGridView. Although the ResultSet is fully populated, as tested using WriteLine, I cannot get it to show in the DataGridView.
What I am trying is this:
reportQuery =
"SELECT * FROM Suppliers";CreateStatement();
ResultSet rs = stmt.executeQuery(reportQuery);
BindingSource bs = new BindingSource();
bs.set_DataSource(rs);
ResultGrid.set_DataSource(bs);
I simply end up with an empty set. Is it possible to show the data in the DataGridView in this way?
Any help would be greatly appreciated,
Regards, Mike
Hi,
Try setting AutoGenerateColumns to true on your DataGridView.
Luc
这篇关于将ResultSet绑定到DataGridView [J#]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!