Click here to Skip to main content
11,928,078 members (47,363 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# C#4.0

I am using C# windows application for importing the data from Excel cells into SQL server 2008. but while importing some data is perfectly imported but some cells data is cutting. due to that some data is lost. please give solution for this issue.

Thank you.
Posted 27-Jun-13 2:35am
ArunRajendra 27-Jun-13 7:37am
Is the data lost random or there is any specific pattern whil trucating?
Ganeshh2 27-Jun-13 7:47am
Hi ArunRajendra,
data lost randomly. some cells data is perfectly imported but some are not imported perfectly..
ArunRajendra 28-Jun-13 0:13am
Can you show the code how you are importing the data from excel?
Ganeshh2 28-Jun-13 0:32am
string excelConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filename + ";Extended Properties=Excel 12.0";
using (OleDbConnection connection = new OleDbConnection(excelConnectionString))
DataTable dtSheetName = connection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
List SubChapters = new List();
int count = 0;
for (int nSheetcount = 0; nSheetcount < dtSheetName.Rows.Count; nSheetcount++)
StringBuilder sSheetNAme = new StringBuilder();
tablename = sSheetNAme.ToString();
string sQuery = "Select * from [" + tablename + "]";
OleDbCommand command = new OleDbCommand(sQuery, connection);
OleDbDataAdapter adapter = new OleDbDataAdapter(command);
if (sSheetNAme.ToString().LastIndexOf("'") == sSheetNAme.ToString().Length - 1)
sSheetNAme.Remove(sSheetNAme.Length - 2, 2);
sSheetNAme.Replace('#', '.');
sSheetNAme.Remove(sSheetNAme.Length - 1, 1);
sSheetNAme.Replace('#', '.');

if (sSheetNAme.ToString().IndexOf("'") == 0)
sSheetNAme.Remove(0, 1);


DataTable Dsheet = new DataTable();
cmdSubChapters.DataSource = SubChapters;
Ganeshh2 28-Jun-13 1:10am

i think it is not imported the data which is having large size i.e greater than 255 characters. Please let me know the solution for importing the large size cell data.

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 27 Jun 2013
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