Click here to Skip to main content
Sign Up to vote bad
good
See more: C#
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 28 Jun '12 - 4:06
Edited 28 Jun '12 - 5:51


2 solutions

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/[^]
  Permalink  
Comments
Ritu khatri - 30 Jun '12 - 1:33
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:20
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:51
Thanx for answer.... and for this what query i write ???
Tim Corey - 1 Jul '12 - 17:33
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[^]
 

Exporting Data to Excel

 
Exporting Data to Excel[^]
 

Thanks
Ashish
  Permalink  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 508
1 Arun Vasu 315
2 Maciej Los 218
3 OriginalGriff 205
4 Aarti Meswania 170
0 Sergey Alexandrovich Kryukov 9,670
1 OriginalGriff 7,409
2 CPallini 3,968
3 Rohan Leuva 3,352
4 Maciej Los 2,861


Advertise | Privacy | Mobile
Web04 | 2.6.130523.1 | Last Updated 28 Jun 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid