Click here to Skip to main content
15,946,529 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:

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.
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<string> SubChapters = new List<string>();
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)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900