Click here to Skip to main content
11,935,066 members (51,744 online)
Rate this:
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 5:06am
Edited 28-Jun-12 6:51am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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

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:[^]
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.
Rate this: bad
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[^]


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

  Print Answers RSS
Top Experts
Last 24hrsThis month

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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100