Click here to Skip to main content
15,915,770 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi. Is there any other way to import an Excel file data to a datatable and load it in Gridview in asp.net 2.0 using c#?

I tried using
C#
OleDbConnection oconn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source="+path+";Extended Properties=Excel 12.0");


and it works in my local machine, but when i deployed it in network(server), it gives an error of

the 'microsoft.ace.oledb.12.0' provider is not registered on the local machine.

I know that i should install something to remove the error and make the web application work, but we are not allowed to install something in the server as it may affect other application integrated with it.

Any help please...
Posted

 
Share this answer
 
Yes, I guess you need to add the reference to your server. Here is the useful links that may helps you:
import excel data to sql server database table and display in gridview[^]
http://stackoverflow.com/questions/21673283/import-excel-data-to-sql-server-database-table-and-display-in-gridview[^]


So, I think Epplus.dll is the best way to import excel data to datatable.
http://www.aspneto.com/import-csv-excel-data-into-sql-server-using-bulk-insert-asp-net.html[^]
 
Share this answer
 
v2
Thank you for all your suggestions! I used this. However, it just accepts Excel in 2003 format

C#
OleDbConnection oconn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties='Excel 12.0;HDR=YES;IMEX=1';");
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900