Databinding with Excel

  • Thread starter Thread starter Julien
  • Start date Start date
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
 
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.
 
Back
Top