Some data is missing when Excel Import. (T.T plz help.)

  • Thread starter Thread starter bluewind44
  • Start date Start date
B

bluewind44

Hello, I made a page that used for import data from .xls files.

At this page, users upload the .xls file to the server, then the app
uses an OleDB connection and the Jet provider to read the data using
the OleDB DataAdapter, then I bind it to a datagrid.

It works fine, but occationally some data is missing on a datagrid,
especially number datas.

Is anyone have same problem? or Is anyone can help me out?



--------
Here's the code that i am using.

DSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + sFileName +
";Extended Properties=\"Excel 8.0;HDR=YES;ReadOnly=0;\"";
objOleCon = new OleDbConnection(DSN);
objOleCon.Open();

dtResult = objOleCon.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new
object[]{null,null,null,"TABLE"});
objOleCon.Close();
if (dtResult.Rows.Count>0)
{
string[] sSheet = new string[dtResult.Rows.Count];
dsExcelDataSet = new DataSet();
dsExcel = new DataSet();

ExcelData = new OleDbDataAdapter("SELECT * FROM
["+dtResult.Rows[0]["TABLE_NAME"].ToString()+"]" , objOleCon);

ExcelData.Fill(dsExcel);
dtExcelData = dsExcel.Tables[0];

}
-----------
 
Things don't happen "occasionally". Develop a simple test that you can post
here that reproduces the problem consistently with as few lines of code as
possible.

Jeff
 
Hello Jeff,

I have a similar problem.
However let me be more specific.

I am trying to read data from an excel sheet using OleDbDataAdapter.
Connection string :
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=filename;Extended
Properties="""" ;Excel 8.0;HDR=No");

cn.Open();
OleDbDataAdapter sda=new OleDbDataAdapter("Select * from
[Sheet1$]",cn);
DataSet ds=new DataSet();
sda.Fill(ds);



where filename should be replaced by the path to the file.
There are no column headers in my file.
I am able to read all the data successfully except when:
A column has a mix of text and numbers.

The text gets read in without a problem.
The numbers do not get read in.


Any suggestions or modifications would be helpful.

Thank You,
Pradeep
 
Back
Top