Hello everyone,
I want to import data from Excel sheet to my SqL Server database using ASP.NET and C#.The data in excel sheet should be imported to the SQL Server table ................tell me the code in C#.net for performing this fuctionality ..............


Thank u ALL !!

Can you please show what work you may have already undertaken on this particular project? The code you're asking for is not really that "easy" to show, and it is heavily dependant upon the format of your spreadsheet, as well as the database schema you want to import into.

I suggest looking into ADO.NET's OleDB data model for loading to and from SQL and the Excel, and then look at SQL Management Objects (SMO) for creating the appropriate tables in your database.

But as an aside, why not use a tool that is good at doing this, like Business Intelligence Development Studio? You can program an SSIS package to run via C#.

Hello everyone,
I want to import data from Excel sheet to my SqL Server database using ASP.NET and C#.The data in excel sheet should be imported to the SQL Server table ................tell me the code in C#.net for performing this fuctionality ..............

Thank u ALL !!

Can you please show what work you may have already undertaken on this particular project? The code you're asking for is not really that "easy" to show, and it is heavily dependant upon the format of your spreadsheet, as well as the database schema you want to import into.

I suggest looking into ADO.NET's OleDB data model for loading to and from SQL and the Excel, and then look at SQL Management Objects (SMO) for creating the appropriate tables in your database.

But as an aside, why not use a tool that is good at doing this, like Business Intelligence Development Studio? You can program an SSIS package to run via C#.

Thanks for your reply ....My project is a web - based application using ASP.NET and C# and it requires that the user should be able to import the excel data into the database ....becoz there are situations when the user has already the information stored in excel and he doesn't want to add the record again that's why my applications requires import option for importing ........ Actually I want to import all the fields of the excel into the two tables...but both table has many fields and there are only 5 columns which I need to export in those two tables and both tables has 10 fields and I need to export only 5 fields from the excel ....

Thanks for your reply ....My project is a web - based application using ASP.NET and C# and it requires that the user should be able to import the excel data into the database ....becoz there are situations when the user has already the information stored in excel and he doesn't want to add the record again that's why my applications requires import option for importing ........ Actually I want to import all the fields of the excel into the two tables...but both table has many fields and there are only 5 columns which I need to export in those two tables and both tables has 10 fields and I need to export only 5 fields from the excel ....

...So what part are you having issues with? Do you not know how to use ADO.Net to read Excel, or write to a SQL server? We can't provide full-fledged code solutions like this-- it is fairly involved, like I mentioned.

Here are some Google searches that might help you out:
Reading Excel from C#:
http://www.google.com/search?q=C%23+read+Excel+file

Writing data to SQL server in C#:
http://www.google.com/search?q=insert+rows+SQL+C%23

This article has been dead for over six months. Start a new discussion instead.