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

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];

}
-----------
 
J

Jeff Dillon

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top