如何使用SqlDataReader填充GridView. [英] How To Fill GridView Using SqlDataReader.

查看:226
本文介绍了如何使用SqlDataReader填充GridView.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..

我正在创建窗口应用程序.完全使用数据集围棋填充,但问题是记录超过200万.

因此,请告诉我如何使用SqlDataReader使用Fill GridView.

我在类文件中创建一个方法,然后创建类文件的对象,然后使用对象.
在...之下

Hi..

I am creating Window Application. Using Dataset completely Gird Fill But Problem is that Record Is more than 20 lakh.

So Please Tell Me How To use The Fill GridView Using SqlDataReader.

I am Creating one Method in Class File then create Object of the class File Then use object..

Which are As under...

public void gridview1(DevExpress.XtraGrid.GridControl grid1, string query)
{
SqlConnection connection = new SlConnection(Connectionstring);
connection.Open();
SqlDataReader reader;
reader = new SqlCommand(query, connection).ExecuteReader();
reader.Read();
grid1.DataSource = reader;
grid1.DataBindings; // Here Error occur. 
connection.Close();
}

My class Object.
program obj = new program()
string query=".....";
obj.gridview1(grd,query); 



P/S:我在Google上搜索了很多天,但仍然找不到确切答案.
请帮帮我!!!

对不起,我的英语不好.很难解释清楚.
希望您能帮助我.

谢谢..
Chirag



P/S: I searched on google for many days, but i still not find answer exactly.
Please help me!!!

I''m sorry, my english is not good. So difficult to explain more clearly.
Hope you try to help me.

Thanks..
Chirag

推荐答案

而不是:
grid1.DataBindings; // Here Error occur. 



试试:



Try:

grid1.DataBind();


这篇关于如何使用SqlDataReader填充GridView.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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