Section 5: Bind the Excel Data to a GridView using an OleDbDataAdapter

In Section 5 of this tutorial by Nannette Thacker, we will learn how to create a connection to our Excel Spreadsheet using an OleDbConnection with a Microsoft.Jet.OLEDB Connection String. We will learn how to create a SELECT query to retrieve data from a given Excel worksheet using an OleDbCommand. We will populate and bind our data to our GridView using an OleDbDataAdapter and DataSet.

We will also look at using Server.MapPath to find a physical directory on the server.

Download the ZIP files:
C#: ShiningStarCExcel.zip
VB: ShiningStarVBExcel.zip

Do you spend hours and hours behind the computer, at the neglect of your spouse or children or parents? I used to think that the more hours I put in and the harder I worked, the more I would be recognized for my accomplishments and rewarded in responsibility and monetarily. However, this is rarely true. The work will always be there the next day. Your children won't. Your spouse may not. If you found out you were going to die tomorrow, would you spend the next 24 hours with your family or behind your computer? I hope you answered your family. Treat them like they're special today. You never know what's going to happen to you or them. We need to balance our lives. Of course we need to work, but we also need to spend quality time with our families and with God.

I denied myself nothing my eyes desired; I refused my heart no pleasure. My heart took delight in all my work, and this was the reward for all my labor. Yet when I surveyed all that my hands had done and what I had toiled to achieve, everything was meaningless, a chasing after the wind; nothing was gained under the sun. Ecclesiastes 2:10-11

What good will it be for a man if he gains the whole world, yet forfeits his soul? Or what can a man give in exchange for his soul? Matthew 16:26


May your dreams be in ASP.NET!
Nannette Thacker

2 Comments

Comments have been disabled for this content.