Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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:06am
Edited 28-Jun-12 5:51am
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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  
v3
Comments
Ritu khatri at 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 at 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 at 1-Jul-12 3:51am
   
Thanx for answer.... and for this what query i write ???
Tim Corey at 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.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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)



Advertise | Privacy | Mobile
Web02 | 2.8.140709.1 | Last Updated 28 Jun 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid