Import excel data from Microsoft excel to SQL Server usin C sharp .net

Hi

Could anyone help me with the sample code in C sharp to import data from excel to SQL server 2005 using C sharp. I have a table called Accounting Calendar ACCT_DATE with 10 columns I have the excel file called example.xls with the same column name as in SQL Server.Please help me with the sample code in C sharp

Thanks

 

 



0
harleen
1/26/2009 8:36:16 PM
asp.net.integration 1945 articles. 0 followers. Follow

5 Replies
1054 Views

Similar Articles

[PageSpeed] 19

 Here's a simple way to do it without the need to have excel installed

http://davidhayden.com/blog/dave/archive/2006/05/26/2973.aspx

 

Hope this helps

Jaime


Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue
http://weblogs.asp.net/JaimedelPalacio
0
jaimedp
1/26/2009 9:03:17 PM

I have 4 projects in my solution one defining Business objects,Logic,data layer and web

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace TargetCorp.AP3.OutboundDatabase.BusinessObjects

{

public class AccountingDate

{

public AccountingDate() { }public DateTime AccountingD

{

get { return accountingD; }

set { accountingD = value; }

}

public int AccountingYearNumber

{

get { return accountingYearNumber; }set { accountingYearNumber = value; }

}

public int AccountingMonthNumber

{

get { return accountingMonthNumber; }

set { accountingMonthNumber = value; }

}

public string AccountingMonthName

{

get { return accountingMonthName; }set { accountingMonthName = value; }

}

public DateTime WeekBeginDate

{

get { return weekBeginDate; }

set { weekBeginDate = value; }

}

public DateTime WeekendDate

{

get { return weekendDate; }set { weekendDate = value; }

}

public int AccountingWeekNumber

{

get { return accountingWeekNumber; }

set { accountingWeekNumber = value; }

}

 

public int AccountingMonthWeekNumber

{

get{ return accountingMonthWeekNumber;}set { accountingMonthWeekNumber = value; }

}

public int AccountingQuarterNumber

{

get { return accountingQuarterNumber; }

set { accountingQuarterNumber = value; }

}

 

public int AccountingQuarterWeekNumber

{

get { return accountingQuarterWeekNumber; }set { accountingQuarterWeekNumber = value; }

}

private DateTime accountingD;

private int accountingYearNumber;

private int accountingMonthNumber;

private string accountingMonthName;

private DateTime weekBeginDate;

private DateTime weekendDate;

private int accountingWeekNumber;

private int accountingMonthWeekNumber;

private int accountingQuarterNumber;

private int accountingQuarterWeekNumber;

}

}

 

 

 

 

DA.cs

 

using System;

using System.Collections.Generic;

using System.Text;

using System.Data.Common;

using Microsoft.Practices.EnterpriseLibrary.Data;

using System.Diagnostics;

using System.Xml;

using System.Collections;

using System.Configuration;

using System.Data;

using System.Data.OleDb;//This namespace is mainly used for dealing with Excel sheet data

using System.Data.SqlClient;

using System.Linq;

using System.Web;

using System.Xml.Linq;

using TargetCorp.AP3.OutboundDatabase.BusinessObjects;

namespace TargetCorp.AP3.OutboundDatabase.DataAccess

{

// private string fileName;

// private string folderName;

// private DataSet dsCSV = new DataSet();

// private DataSet ConnectFile()

// {

// DataSet ds = new DataSet();

// try

// {

// string ConnectionString, CommandText;

// OleDbConnection conn;

// OleDbCommand Command;

// ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + folderName + ";Extended Properties='text;HDR=Yes;FMT=Delimited'";

// CommandText = "select * from [" + fileName + "]";

// using (conn = new System.Data.OleDb.OleDbConnection(ConnectionString))

// {

// Command = new System.Data.OleDb.OleDbCommand(CommandText, conn);

// conn.Open();

// System.Data.OleDb.OleDbDataAdapter da = new System.Data.OleDb.OleDbDataAdapter(CommandText, conn);

// da.Fill(ds, "FASClient");

// }

// }

// catch (Exception ex)

// {

// MessageBox.Show(ex.Message.ToString());

// }

// return ds;

// }

// private void btnSelectFile_Click(object sender, EventArgs e)

// {

// OpenFileDialog fileLookUp = new OpenFileDialog();

// fileLookUp.Title = "Get File";

// fileLookUp.Filter = "Files (*.csv)|*.csv|All Files (*.*)|*.*";

// if (fileLookUp.ShowDialog() == DialogResult.OK)

// {

// txtFileName.Text = fileLookUp.FileName;

// fileName = Path.GetFileName(txtFileName.Text);

// folderName = Path.GetDirectoryName(txtFileName.Text);

// }

// }

// private void btnReadFile_Click(object sender, EventArgs e)

// {

// if (string.IsNullOrEmpty(txtFileName.Text))

// lblError.Text = "Please select the 'CSV file' and click 'Process'.";

// else

// {

// dsCSV = ConnectFile();

// if (dsCSV.Tables.Count > 0 && dsCSV.Tables[0] != null)

// {

// dgCSV.DataSource = dsCSV.Tables[0];

// }

// }

// }

// private void btnProcess_Click(object sender, EventArgs e)

// {

// string xmldata = dsCSV.GetXml().ToString();

// SqlConnection oSqlConn = null;

// SqlCommand oSqlCmd = null;

// try

// {

// string cConnStr = string.Empty;

// ConnectionStringSettings connSettings = ConfigurationManager.ConnectionStrings["SQLConn"];

// if (connSettings != null)

// cConnStr = connSettings.ConnectionString;

// using (oSqlConn = new SqlConnection(cConnStr))

// {

// oSqlConn.Open();

// // Create a command to select the iid for HRCCountry table

// oSqlCmd = new SqlCommand("usp_Import_Client", oSqlConn);

// oSqlCmd.CommandType = CommandType.StoredProcedure;

// oSqlCmd.CommandTimeout = 0;

// oSqlCmd.Parameters.AddWithValue("@cFasClient", xmldata);

// int recsAffected = oSqlCmd.ExecuteNonQuery();

// MessageBox.Show("Successfully processed the records");

// }

// }

// catch (SqlException sqlex)

// {

// MessageBox.Show(sqlex.Message.ToString());

// }

// catch (Exception ex)

// {

// MessageBox.Show(ex.Message.ToString());

// }

// }

//}

// public class AccountingDateDA

// {

// Database db = DatabaseFactory.CreateDatabase("OutboundDatabaseDataAccess");

// string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=example.xls;ExtendedProperties=""Excel 8.0;HDR=YES;""";

// DbProviderFactory factory = DbProviderFactories.GetFactory("System.Data.OleDb");

// using (DbConnection connection = factory.CreateConnection())

// {

// connection.ConnectionString = connectionString;

// using (DbCommand command = connection.CreateCommand())

// {

// // Cities$ comes from the name of the worksheet

// command.CommandText = "SELECT ACCT_D,ACCT_YR_I FROM [Sheet1$]";

// connection.Open();

// using (DbDataReader dr = command.ExecuteReader())

// {

// while (dr.Read())

// {

// Debug.WriteLine(dr["ACCT_D"].ToString());

// }

// }

// }

// }

// }

// }

//}



0
harleen
1/28/2009 8:00:56 PM

I have 4 projects in my solution one defining Business objects,Logic,data layer and web

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace TargetCorp.AP3.OutboundDatabase.BusinessObjects

{

public class AccountingDate

{

public AccountingDate() { }public DateTime AccountingD

{

get { return accountingD; }

set { accountingD = value; }

}

public int AccountingYearNumber

{

get { return accountingYearNumber; }set { accountingYearNumber = value; }

}

public int AccountingMonthNumber

{

get { return accountingMonthNumber; }

set { accountingMonthNumber = value; }

}

public string AccountingMonthName

{

get { return accountingMonthName; }set { accountingMonthName = value; }

}

public DateTime WeekBeginDate

{

get { return weekBeginDate; }

set { weekBeginDate = value; }

}

public DateTime WeekendDate

{

get { return weekendDate; }set { weekendDate = value; }

}

public int AccountingWeekNumber

{

get { return accountingWeekNumber; }

set { accountingWeekNumber = value; }

}

 

public int AccountingMonthWeekNumber

{

get{ return accountingMonthWeekNumber;}set { accountingMonthWeekNumber = value; }

}

public int AccountingQuarterNumber

{

get { return accountingQuarterNumber; }

set { accountingQuarterNumber = value; }

}

 

public int AccountingQuarterWeekNumber

{

get { return accountingQuarterWeekNumber; }set { accountingQuarterWeekNumber = value; }

}

private DateTime accountingD;

private int accountingYearNumber;

private int accountingMonthNumber;

private string accountingMonthName;

private DateTime weekBeginDate;

private DateTime weekendDate;

private int accountingWeekNumber;

private int accountingMonthWeekNumber;

private int accountingQuarterNumber;

private int accountingQuarterWeekNumber;

}

}

 

 

 

 

DA.cs

 

using System;

using System.Collections.Generic;

using System.Text;

using System.Data.Common;

using Microsoft.Practices.EnterpriseLibrary.Data;

using System.Diagnostics;

using System.Xml;

using System.Collections;

using System.Configuration;

using System.Data;

using System.Data.OleDb;//This namespace is mainly used for dealing with Excel sheet data

using System.Data.SqlClient;

using System.Linq;

using System.Web;

using System.Xml.Linq;

using TargetCorp.AP3.OutboundDatabase.BusinessObjects;

namespace TargetCorp.AP3.OutboundDatabase.DataAccess

{

// private string fileName;

// private string folderName;

// private DataSet dsCSV = new DataSet();

// private DataSet ConnectFile()

// {

// DataSet ds = new DataSet();

// try

// {

// string ConnectionString, CommandText;

// OleDbConnection conn;

// OleDbCommand Command;

// ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + folderName + ";Extended Properties='text;HDR=Yes;FMT=Delimited'";

// CommandText = "select * from [" + fileName + "]";

// using (conn = new System.Data.OleDb.OleDbConnection(ConnectionString))

// {

// Command = new System.Data.OleDb.OleDbCommand(CommandText, conn);

// conn.Open();

// System.Data.OleDb.OleDbDataAdapter da = new System.Data.OleDb.OleDbDataAdapter(CommandText, conn);

// da.Fill(ds, "FASClient");

// }

// }

// catch (Exception ex)

// {

// MessageBox.Show(ex.Message.ToString());

// }

// return ds;

// }

// private void btnSelectFile_Click(object sender, EventArgs e)

// {

// OpenFileDialog fileLookUp = new OpenFileDialog();

// fileLookUp.Title = "Get File";

// fileLookUp.Filter = "Files (*.csv)|*.csv|All Files (*.*)|*.*";

// if (fileLookUp.ShowDialog() == DialogResult.OK)

// {

// txtFileName.Text = fileLookUp.FileName;

// fileName = Path.GetFileName(txtFileName.Text);

// folderName = Path.GetDirectoryName(txtFileName.Text);

// }

// }

// private void btnReadFile_Click(object sender, EventArgs e)

// {

// if (string.IsNullOrEmpty(txtFileName.Text))

// lblError.Text = "Please select the 'CSV file' and click 'Process'.";

// else

// {

// dsCSV = ConnectFile();

// if (dsCSV.Tables.Count > 0 && dsCSV.Tables[0] != null)

// {

// dgCSV.DataSource = dsCSV.Tables[0];

// }

// }

// }

// private void btnProcess_Click(object sender, EventArgs e)

// {

// string xmldata = dsCSV.GetXml().ToString();

// SqlConnection oSqlConn = null;

// SqlCommand oSqlCmd = null;

// try

// {

// string cConnStr = string.Empty;

// ConnectionStringSettings connSettings = ConfigurationManager.ConnectionStrings["SQLConn"];

// if (connSettings != null)

// cConnStr = connSettings.ConnectionString;

// using (oSqlConn = new SqlConnection(cConnStr))

// {

// oSqlConn.Open();

// // Create a command to select the iid for HRCCountry table

// oSqlCmd = new SqlCommand("usp_Import_Client", oSqlConn);

// oSqlCmd.CommandType = CommandType.StoredProcedure;

// oSqlCmd.CommandTimeout = 0;

// oSqlCmd.Parameters.AddWithValue("@cFasClient", xmldata);

// int recsAffected = oSqlCmd.ExecuteNonQuery();

// MessageBox.Show("Successfully processed the records");

// }

// }

// catch (SqlException sqlex)

// {

// MessageBox.Show(sqlex.Message.ToString());

// }

// catch (Exception ex)

// {

// MessageBox.Show(ex.Message.ToString());

// }

// }

//}

// public class AccountingDateDA

// {

// Database db = DatabaseFactory.CreateDatabase("OutboundDatabaseDataAccess");

// string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=example.xls;ExtendedProperties=""Excel 8.0;HDR=YES;""";

// DbProviderFactory factory = DbProviderFactories.GetFactory("System.Data.OleDb");

// using (DbConnection connection = factory.CreateConnection())

// {

// connection.ConnectionString = connectionString;

// using (DbCommand command = connection.CreateCommand())

// {

// // Cities$ comes from the name of the worksheet

// command.CommandText = "SELECT ACCT_D,ACCT_YR_I FROM [Sheet1$]";

// connection.Open();

// using (DbDataReader dr = command.ExecuteReader())

// {

// while (dr.Read())

// {

// Debug.WriteLine(dr["ACCT_D"].ToString());

// }

// }

// }

// }

// }

// }

//}



0
harleen
1/28/2009 8:00:59 PM

I have 4 projects in my solution one defining Business objects,Logic,data layer and web

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace TargetCorp.AP3.OutboundDatabase.BusinessObjects

{

public class AccountingDate

{

public AccountingDate() { }public DateTime AccountingD

{

get { return accountingD; }

set { accountingD = value; }

}

public int AccountingYearNumber

{

get { return accountingYearNumber; }set { accountingYearNumber = value; }

}

public int AccountingMonthNumber

{

get { return accountingMonthNumber; }

set { accountingMonthNumber = value; }

}

public string AccountingMonthName

{

get { return accountingMonthName; }set { accountingMonthName = value; }

}

public DateTime WeekBeginDate

{

get { return weekBeginDate; }

set { weekBeginDate = value; }

}

public DateTime WeekendDate

{

get { return weekendDate; }set { weekendDate = value; }

}

public int AccountingWeekNumber

{

get { return accountingWeekNumber; }

set { accountingWeekNumber = value; }

}

 

public int AccountingMonthWeekNumber

{

get{ return accountingMonthWeekNumber;}set { accountingMonthWeekNumber = value; }

}

public int AccountingQuarterNumber

{

get { return accountingQuarterNumber; }

set { accountingQuarterNumber = value; }

}

 

public int AccountingQuarterWeekNumber

{

get { return accountingQuarterWeekNumber; }set { accountingQuarterWeekNumber = value; }

}

private DateTime accountingD;

private int accountingYearNumber;

private int accountingMonthNumber;

private string accountingMonthName;

private DateTime weekBeginDate;

private DateTime weekendDate;

private int accountingWeekNumber;

private int accountingMonthWeekNumber;

private int accountingQuarterNumber;

private int accountingQuarterWeekNumber;

}

}

 

 

 

 

DA.cs

 

using System;

using System.Collections.Generic;

using System.Text;

using System.Data.Common;

using Microsoft.Practices.EnterpriseLibrary.Data;

using System.Diagnostics;

using System.Xml;

using System.Collections;

using System.Configuration;

using System.Data;

using System.Data.OleDb;//This namespace is mainly used for dealing with Excel sheet data

using System.Data.SqlClient;

using System.Linq;

using System.Web;

using System.Xml.Linq;

using TargetCorp.AP3.OutboundDatabase.BusinessObjects;

namespace TargetCorp.AP3.OutboundDatabase.DataAccess

{

// private string fileName;

// private string folderName;

// private DataSet dsCSV = new DataSet();

// private DataSet ConnectFile()

// {

// DataSet ds = new DataSet();

// try

// {

// string ConnectionString, CommandText;

// OleDbConnection conn;

// OleDbCommand Command;

// ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + folderName + ";Extended Properties='text;HDR=Yes;FMT=Delimited'";

// CommandText = "select * from [" + fileName + "]";

// using (conn = new System.Data.OleDb.OleDbConnection(ConnectionString))

// {

// Command = new System.Data.OleDb.OleDbCommand(CommandText, conn);

// conn.Open();

// System.Data.OleDb.OleDbDataAdapter da = new System.Data.OleDb.OleDbDataAdapter(CommandText, conn);

// da.Fill(ds, "FASClient");

// }

// }

// catch (Exception ex)

// {

// MessageBox.Show(ex.Message.ToString());

// }

// return ds;

// }

// private void btnSelectFile_Click(object sender, EventArgs e)

// {

// OpenFileDialog fileLookUp = new OpenFileDialog();

// fileLookUp.Title = "Get File";

// fileLookUp.Filter = "Files (*.csv)|*.csv|All Files (*.*)|*.*";

// if (fileLookUp.ShowDialog() == DialogResult.OK)

// {

// txtFileName.Text = fileLookUp.FileName;

// fileName = Path.GetFileName(txtFileName.Text);

// folderName = Path.GetDirectoryName(txtFileName.Text);

// }

// }

// private void btnReadFile_Click(object sender, EventArgs e)

// {

// if (string.IsNullOrEmpty(txtFileName.Text))

// lblError.Text = "Please select the 'CSV file' and click 'Process'.";

// else

// {

// dsCSV = ConnectFile();

// if (dsCSV.Tables.Count > 0 && dsCSV.Tables[0] != null)

// {

// dgCSV.DataSource = dsCSV.Tables[0];

// }

// }

// }

// private void btnProcess_Click(object sender, EventArgs e)

// {

// string xmldata = dsCSV.GetXml().ToString();

// SqlConnection oSqlConn = null;

// SqlCommand oSqlCmd = null;

// try

// {

// string cConnStr = string.Empty;

// ConnectionStringSettings connSettings = ConfigurationManager.ConnectionStrings["SQLConn"];

// if (connSettings != null)

// cConnStr = connSettings.ConnectionString;

// using (oSqlConn = new SqlConnection(cConnStr))

// {

// oSqlConn.Open();

// // Create a command to select the iid for HRCCountry table

// oSqlCmd = new SqlCommand("usp_Import_Client", oSqlConn);

// oSqlCmd.CommandType = CommandType.StoredProcedure;

// oSqlCmd.CommandTimeout = 0;

// oSqlCmd.Parameters.AddWithValue("@cFasClient", xmldata);

// int recsAffected = oSqlCmd.ExecuteNonQuery();

// MessageBox.Show("Successfully processed the records");

// }

// }

// catch (SqlException sqlex)

// {

// MessageBox.Show(sqlex.Message.ToString());

// }

// catch (Exception ex)

// {

// MessageBox.Show(ex.Message.ToString());

// }

// }

//}

// public class AccountingDateDA

// {

// Database db = DatabaseFactory.CreateDatabase("OutboundDatabaseDataAccess");

// string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=example.xls;ExtendedProperties=""Excel 8.0;HDR=YES;""";

// DbProviderFactory factory = DbProviderFactories.GetFactory("System.Data.OleDb");

// using (DbConnection connection = factory.CreateConnection())

// {

// connection.ConnectionString = connectionString;

// using (DbCommand command = connection.CreateCommand())

// {

// // Cities$ comes from the name of the worksheet

// command.CommandText = "SELECT ACCT_D,ACCT_YR_I FROM [Sheet1$]";

// connection.Open();

// using (DbDataReader dr = command.ExecuteReader())

// {

// while (dr.Read())

// {

// Debug.WriteLine(dr["ACCT_D"].ToString());

// }

// }

// }

// }

// }

// }

//}



0
harleen
1/28/2009 8:01:13 PM

you can use OLEDB to export data .

                MyConnection = new System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Data Source='c:\\csharp.net-informations.xls';Extended Properties=Excel 8.0;");

                sql = "Insert into [Sheet1$] (id,name) values('5','e')";
                myCommand.CommandText = sql;
If you want the full source code , check with the following link.

http://csharp.net-informations.com/excel/csharp-excel-oledb-insert.htm

bolton. 

 

0
boltonss
3/23/2009 7:05:16 AM
Reply:

Similar Artilces:

How to Data Transfer From Excel to Microsoft SQL Server Data base Using .Net.
Hai All, How to Data Transfer From Excel to Microsoft SQL Server Data base Using .Net. I have one Excel Sheet in that sheet 15 Fields (attributes) and 3000 records are there. In this 3000 records i want to store this (Excel) data into  5 related tables on Sql Server Database Using .Net.   How to store Excel Sheet data into Sql Server database. Please help me as soon as possible. Thank You Very Much...Have a Good Day... With RegardsSridhar...

How to Import data from Excel into MS SQL in .Net?
Hi, I'm building a web application in VB.NET 1.1 where users will upload Excel files at this webpage and the web application will transfer the data from the uploaded Excel file into MS SQL 2000. There are around 600-700 records and about 56 columns in the Excel file which is to be uploaded daily. There will be a few different files which I need to implement for as well.  I've sourced for and tried alot of methods. But either they can't satisfy my requirements or they just can't simply work. - Most simple and direct way I've tried is creating a oledb connection to...

import Excel data into a SQL Server table using C#.
Hi, i have requirement to import Excel file data into a SQL Server table using C#. If any one have code for this or any link for reference. thanks in advance vikrant...

Using VB.NET to export data from SQL Server 2005 to Excel
Hi There, I just want to know how to export data from SQL Server 2005 to an excel spread sheet, using VB.NET?ThanksSJB  Everytime I should export data from SQL to Excel with code, I simply create a ; seperated file (*.csv). So if you want to do the same you can simply use ADO.Net to query your database and get a result set from your tables. Walk trough the rows and get its value and create a textfile with the System.IO namespace. The file can look like: column1;column2;column3 value1;value2;value3 value1;value2;value3 The first row can if you want have the name of the column tha...

Import data from Excel to sql server 2005 not working on server
I am trying to import data from an Excel file into SQL Server 2005 in a webform.  The code below works on my local machine, but on the Production server it throws an unspecified OLEDB error at OleDbConn.Open when attempting to open the connection.  I cannot figure out what is required on the server to make this work, as the error gives no details.  I do not have Excel installed on the webserver and do have it on my local, but don't know if that is the problem, because I get the same error when I change the connectionstring to open a CSV file.   Any help wo...

How to Import data from excel sheet within SQL Client into SQL Server
 Hi All,   I need to  import data from excel sheet to SQL Database in SQL Server.I already done it in machine which SQL Server run.but I cant do it within SQL Client machine.while try to do it this error was occure Server: Msg 7302, Level 16, State 1, Line 2Could not create an instance of OLE DB provider 'Microsoft.Jet.OLEDB.4.0'.Please tell me How I do itThanks,Harsha Hi harsha  Can you post your code  If this post helps you, please mark it as Answer.Gnana Prakash SSoftware EngineerCoimbatorehttp://www.sgnanaprakash.com  Hi Gnana,this is My...

Import data from excel sheet data to Sql Server 2008 database
 Hello,  I am doing an project in which i am going to get the data from the excel sheet and insert it into My SQL Server 2005 database.How can i do it,can any one help me out to get me out of this problem with an example. You could use SQL Server Integration Services (SSIS) to do this.  If you need to repeat the process remember that you can host an SSIS package as a SQL Agent job and run it repeatedly, and you can kick off the job from code. A walkthrough of this is here: http://www.builderau.com.au/program/sqlserver/soa/How-to-import-an-Excel-file-into-SQL-Server-2005-us...

SpreadsheetGear for .NET Release Candidate, a royalty free Microsoft Excel spreadsheet component for the Microsoft .NET Framework, is available for download.
9/12/2005 - SpreadsheetGear for .NET is a royalty free Microsoft Excel compatible spreadsheet component built by industry veterans for the Microsoft .NET Framework. SpreadsheetGear for .NET provides .NET Framework developers the tool they need to leverage the existing skills of Excel users by allowing these users to design reports, specify business rules, set up complex calculations and provide tables of data in a form in which they are both knowledgeable and comfortable. SpreadsheetGear for .NET features the fastest spreadsheet calculation engine available. All of Excel's financial, date, ...

Importing datas from Excel to Sql Server
Hi, I am developping in asp.net, c#. I am importing datas from an excel sheet and I am saving them in some tables in my Sql Server. This works for these value types : SqlServerType            .aspx pages            Statestring                            varchar            &n...

How to import data from Excel to SQL Server
 I have an excel sheet and a table in sql server 2005 with the same field as in excel sheet .Please let me know how do import all data from excel sheet to sql server 2005.there are some extra rows in the table.. the easiest way is to open your table with right click- "open table",select and copy all cells from  Excel ,on opened table click the star in last row.. and past.Other way is :Right click on Database--> tasks --> Import data... and follow the wizard Regards,Stefan Uzunov I would use DTS to do the import, there are lots of examples out there showi...

Import Excel data to SQL Server
Hi, I have a problem of importing excel data into the SQL database. When I import the database (finish all importing steps), it tell me "Fail to copy 1 table" and I go to view the error message say that "Error at Source for Row number 19. Errors encountered so fat in the task: 1. Data for source column 2 ('Notes') is too large for the specified buffer size." I try to remove that line record but still have many lines have the same problem. So, can I change the importing buffer size in SQL Server to make me import data becomes successful?? Thanks a lot. you're pr...

Excel data import to SQL Server Problem
Hi, I am importing data from excel sheet into SQL Server table using the SQLBulk but getting this error "The given ColumnMapping does not match up with any column in the source or destination." Please someone help me...Farid ud din Masood.If you really got help, Help me as well.Click "Mark As Answer"  hi,the Sql Server 2005 destination columns are case sensitive. ...

SqlBulkCopy import excel data into SQL Server
 I use SqlBulkCopy import excel data into SQL Server, and here have 2 columns (Title and Name)Database have 3 fields : Title, Name and USER_ID Q1. USER_ID, i would like to generate by the Application, how can i add a row in the SqlBulkCopy ? Q2. Also i would to like to check the Name should have value, where can i place the code?   Thanks so much!1 string excelConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + ConfigurationManager.AppSettings["excelpath"] + ";Extended Properties=" + '"' + "Excel 8.0;HDR=...

Import data from excel sheet to SQL Server
How do I import the data from the excel sheel to the database table that has different fields compared to that of the excel sheet programatically or as a SysAd?I never lose, some people are just better than me at winning. INSERT INTO [dbo].[products]  ( [Stock Number], [Registration Number] )SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=C:\stock.xls','SELECT * FROM [Expoted_Stock$]')    When i run this query it is giving error Msg 7357, Level 16, State 2, Line 2Cannot process the object "SELECT * FROM [Expoted_Stock...