Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
| Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old April 5th, 2008, 12:59 AM
Registered User
Join Date: Apr 2008
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default import from excel to sql database

[font=Arial]hi iam using visul studio 2005 c# i want to import data from excel work sheet to sql database 2005 so that i need ur idea
and also code for c#

reply me as soon as possible

                                                                                                          s.manigandan :)

  #2 (permalink)  
Old April 5th, 2008, 02:53 AM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts

Generally these forums are to help people with specific problems, not to do their work (homework?) for them.

Try searching the internet (Google or other leading search providers can help) as I'm sure you're not the first person to want to do this.

/- Sam Judson : Wrox Technical Editor -/
  #3 (permalink)  
Old March 5th, 2010, 05:34 AM
Registered User
Join Date: Mar 2010
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts


you can easily import Excel to DataTable with this Excel C# library, then use DataAdapters or ADO.NET to fill database with data from DataTable.

Here is a code snippet how to import Excel to DataTable with GemBox.Spreadsheet Excel .NET component:
ExcelFile ef =  new ExcelFile();
DataTable dataTable = new DataTable();

// Depending on the format of the input file, you need to change this:
dataTable.Columns.Add("FirstName", typeof(string));
dataTable.Columns.Add("LastName", typeof(string));

// Load Excel file.

// Select the first worksheet from the file.
ExcelWorksheet ws = ef.Worksheets[0];

// Extract the data from the worksheet to the DataTable.
// Data is extracted starting at first row and first column for 10 rows or until the first empty row appears.
ws.ExtractToDataTable(dataTable, 10, ExtractDataOptions.StopAtFirstEmptyRow, ws.Rows[0], ws.Columns[0]);

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to import excel data into sql server khaink ASP.NET 1.0 and 1.1 Basics 1 July 31st, 2007 09:10 PM
Import Excel file to back end database ghall202 Access VBA 1 June 7th, 2007 11:56 AM
Import Excel File to access database Komila ASP.NET 1.0 and 1.1 Professional 7 October 7th, 2006 12:45 AM
How to import from excel to database(sql) in .net jvraman General .NET 1 May 18th, 2006 05:51 AM
how to import data from excel,csv into sql server therisingsun ASP.NET 1.0 and 1.1 Basics 2 October 1st, 2005 12:17 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.