Click here to Skip to main content
15,881,600 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want c# code for import and export (excel to SQL server database), but I don't understand the code and connection sting, so please help me to understand the following code:

string excelConnectionString = @Provider=Microsoft.Jet.OLEDB.4.0;Data Source=NEETIN-PC\\SQLEXPRESS; Initial Catalog=data;Integrated Security=True; Extended Properties=Microsoft Office Excel 2003;HDR=YES;

What do I write in Provider and Extended Properties?
Posted
Updated 28-Jun-12 5:51am
v3

Here are a couple articles that explains how to do all of this:

http://www.c-sharpcorner.com/uploadfile/ae35ca/read-and-write-excel-data-using-C-Sharp/[^]

Reading and Writing Excel using OLEDB[^]

As for your connection string question, use this site to help generate the correct connection string for your version of Excel:

http://www.connectionstrings.com/[^]
 
Share this answer
 
v3
Comments
Ritu khatri 30-Jun-12 1:33am    
i used this code and successfully it work but when i second time click the button then the data will fill second time i want that same data is not insert it will overwrite
Tim Corey 30-Jun-12 12:20pm    
That means that you have a working solution for this question. Now you have a new issue - the logic of your application has not been properly designed. On your button click, you first need to verify if the data exists or not. If it exists, you should overwrite it. If not, you should insert it.
Ritu khatri 1-Jul-12 3:51am    
Thanx for answer.... and for this what query i write ???
Tim Corey 1-Jul-12 17:33pm    
I can't tell you what query to write. That will be up to you based upon your data and your environment. Download a couple examples and get them working. Then start modifying them for your own use.
Please follow the links of running code..

Import Data from excel to SQL server using C# in ASP. NET

Import Data from excel to SQL server using C# in ASP. NET[^]

<br />
Exporting Data to Excel


Exporting Data to Excel[^]


Thanks
Ashish
 
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