I have to insert certain data in excel to sql database on weekly basis & also has to dump a report shown in gridview control to excel so can anyone help me to import data from excel to datagrid view so that user can upload in one click.And how to export in excel from gridview.plz help me ,its urgent 4 me.

9 Years
Discussion Span
Last Post by LizR

I'm not certain I understand your question or what you need help with. (Specific questions usually get faster and better answers.)

Are you saying that you need to write an application that will be run weekly to extract data from an Excel worksheet and insert it into an SQL database?

The application should also display the data that it is adding (or did add) to the database in a datagrid so the user can view it?

Does the datagrid view need to happen before putting the data in the database? (Is it some form of verification step?)

How does the application know where to find the Excel worksheet?

What data from the Excel worksheet needs to be added to the database?

I suspect that your application will be using COM automation to have open Excel and read the data from the worksheet. (I've done this from Python quite effectively and it should be easier in C#)

You then load the data you extract into the datagrid.

Once the user 'approves' the data, you would generate SQL statements to insert or update the data in the database.

Based on the given information that's about all I can come up with.

If you want more assistance, show us what you have done, or what you're having problems with.


There are a shed load of posts in this forum about reading, writing and manipulating excel through c#, most of which contain code.

Please search, then when you get stuck on a specific bit and youv'e written code and its not working, post the code, and we'll try help.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.