Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
Hi,
 
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
Comments
ArunRajendra at 27-Jun-13 7:37am
   
Is the data lost random or there is any specific pattern whil trucating?
Ganeshh2 at 27-Jun-13 7:47am
   
Hi ArunRajendra,
data lost randomly. some cells data is perfectly imported but some are not imported perfectly..
ArunRajendra at 28-Jun-13 0:13am
   
Can you show the code how you are importing the data from excel?
Ganeshh2 at 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))
{
connection.Open();
DataTable dtSheetName = connection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
List SubChapters = new List();
SubChapters.Add("--Select--");
int count = 0;
for (int nSheetcount = 0; nSheetcount < dtSheetName.Rows.Count; nSheetcount++)
{
count++;
StringBuilder sSheetNAme = new StringBuilder();
sSheetNAme.Append(dtSheetName.Rows[nSheetcount]["TABLE_NAME"].ToString());
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('#', '.');
}
else
{
sSheetNAme.Remove(sSheetNAme.Length - 1, 1);
sSheetNAme.Replace('#', '.');
}

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

SubChapters.Add(sSheetNAme.ToString());

DataTable Dsheet = new DataTable();
adapter.Fill(Dsheet);
dataset.Tables.Add(Dsheet);
}
cmdSubChapters.DataSource = SubChapters;
}
Ganeshh2 at 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
0 CPallini 235
1 DamithSL 225
2 OriginalGriff 198
3 George Jonsson 170
4 Maciej Los 165
0 OriginalGriff 5,305
1 DamithSL 4,382
2 Maciej Los 3,760
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,901


Advertise | Privacy | Mobile
Web01 | 2.8.141216.1 | Last Updated 27 Jun 2013
Copyright © CodeProject, 1999-2014
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