Fill DataGridView with command

Technical support for Spire.DataExport

Moderators: iceblue support, DataExport, Manager

Fill DataGridView with command

Postby tom » Thu Feb 24, 2011 2:45 am

I want to assign the data source of the DataGridView with the oleDbCommand, but I failed. The code:
dataGridView.DataSource = oleDbCommand;
I want your help. Thank you.
tom
 
Posts: 14
Joined: Tue Nov 30, 2010 7:21 am

Re: Fill DataGridView with command

Postby iceblue support » Fri Feb 25, 2011 3:53 am

If you want to do so, you should use a data adapter, it like a intermediary of the command and DataGridView. You may use it with the following code: OleDbDataAdapter da = new OleDbDataAdapter(oleDbCommand);
DataTable dt = new DataTable();
da.Fill(dt);
dataGridView.DataSource = dt;
e-iceblue support
User avatar
iceblue support
 
Posts: 244
Joined: Tue Dec 21, 2010 2:56 am


Return to Spire.DataExport

Who is online

Users browsing this forum: No registered users and 2 guests

cron