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 Sergey Alexandrovich Kryukov 535
1 Kornfeld Eliyahu Peter 407
2 Maciej Los 369
3 DamithSL 221
4 OriginalGriff 218
0 OriginalGriff 6,353
1 DamithSL 4,854
2 Maciej Los 4,476
3 Kornfeld Eliyahu Peter 4,058
4 Sergey Alexandrovich Kryukov 3,917


Advertise | Privacy | Mobile
Web04 | 2.8.141223.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