473,394 Members | 1,709 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Databinding with Excel

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
Nov 15 '05 #1
2 2043
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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Julien" <ju************@heuft.com> wrote in message
news:ey**************@tk2msftngp13.phx.gbl...
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

Nov 15 '05 #2
It could be a problem with the version of ADO you are using.
Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Kevin Swanson | last post by:
I'm writing what should be a very simple app against an Oracle database. The app has a number of user controls, any one of which is loaded into a main display page using the loadControl method,...
3
by: John Bailey | last post by:
When I first built a few web pages in ASP .Net 2.0, I thought it was great. The formview and detailview contorls would automatically layout the controls for you, the update methods were...
4
by: Nathan Sokalski | last post by:
I have two databinding expressions (the first & last names from a DB) that I want to assign to the text property of a Label so that the result is LASTNAME,FIRSTNAME. At the moment, I have the...
0
by: Richard Grene | last post by:
I am binding an excel sheet with a datagrid using oledataconnection. The problem I have is one of my Excel columns is filled with Invoice Numbers and some numbers are numeric and some have...
9
by: Dennis | last post by:
I have tried using Databinding for my application but always seem to find it very restrictive (maybe I don't completely understand it enough). I always seem to find it much easier to display a...
8
by: GaryDean | last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much in answers so I'm reposting some questions posted by some of the programmers here in our organization that never got...
0
by: Wayne Sepega | last post by:
I have the following Object DataSource <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetCustomer" TypeName="Customers" DataObjectTypeName="Customer"...
8
by: Dirk | last post by:
Hello, I have a problem to use databinding with my business layer classes. My data class does not have simple properties (string, int or datetime), instead, all my properties are objects of the...
1
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post by:
Hello to all, I want to know if DataBinding in asp.net 2,0 is better than to fill up the values of the controls of the following form: this.miControlTextBox.Text = valorParaControlTextbox; ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.