将ResultSet绑定到DataGridView [J#] [英] Binding ResultSet to DataGridView [J#]

查看:86
本文介绍了将ResultSet绑定到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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆