Databinding with Excel

J

Julien

Hi !!

I try to collect information from my Excel file into a datagrid but nothing
happens with this code :

================================================================
strConn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program
Files\concentrator\example\CounterDDE.xls;Extended Properties=Excel 8.0;";

OleDbConnection oConn = new OleDbConnection();
oConn.ConnectionString = strConn;
oConn.Open();

OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM counter_range",
oConn);
DataSet ds = new DataSet();
da.Fill(ds);
dataGrid1.DataSource = ds.Tables[0].DefaultView;

oConn.Close();
===============================================================

what's wrong ? did I forget something ?
What I could not understand is why I can't do a databind() in winforms...
i'm pretty sure that the problem comes from : dataGrid1.DataSource =
ds.Tables[0].DefaultView;

thanks,

Julien
 
N

Nicholas Paldino [.NET/C# MVP]

Julien,

Are you sure that you are getting data from the dataset after the call
to Fill on the data adapter? If you save the XML of the data set after the
call to Fill, is there anything in it?

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top