473,399 Members | 4,254 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

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

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.Tabl es, 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];

}
-----------

Apr 20 '06 #1
4 2320
Occasionally? Don't think so. Reproduce

"bluewind44" <bl********@gmail.com> wrote in message
news:11**********************@t31g2000cwb.googlegr oups.com...
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.Tabl es, 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];

}
-----------

Apr 21 '06 #2
Reproduce?

What do you mean? @.@

Apr 25 '06 #3
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

"bluewind44" <bl********@gmail.com> wrote in message
news:11********************@j33g2000cwa.googlegrou ps.com...
Reproduce?

What do you mean? @.@

Apr 25 '06 #4

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
"Jeff Dillon" wrote:
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

"bluewind44" <bl********@gmail.com> wrote in message
news:11********************@j33g2000cwa.googlegrou ps.com...
Reproduce?

What do you mean? @.@


May 1 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: svilen | last post by:
hello again. i'm now into using python instead of another language(s) for describing structures of data, including names, structure, type-checks, conversions, value-validations, metadata etc....
2
by: Mr. Bungle | last post by:
When importing excel from access I am fully aware that one can import directly into a table. Can you get as specific via code or something to import data from an excel sheet to a FORM (Not Table)...
8
by: harry | last post by:
Hi Folks: I'm trying to do something that looks simple, but I can't make it work right. It's Access 2000 on a Win2000 computer. I create a database with 5 columbs. The data I need to import...
2
by: aland | last post by:
I've got an Excel spread sheet with one row of id's and I'd like to use these in a query and put the results into Excel. Basically I'd like to do something like SELECT txtFileTitle, txtFileYear...
2
by: Hans Wien | last post by:
I have to write a lot of data to excel for analysts who use it further from there but would like to use managed C++ and not C# since a lot of code is involved which already exists now in managed...
2
by: Sreedhar Vankayala | last post by:
Hi, I joined a project where we need to import data from a excel file into sql server via the asp.net. After doing a long research found that #1. Upload Excel file to the server #2. Load or...
3
by: Schultz | last post by:
I would like to know if it is possible to import data from MS Excel 2000 to a dataset using asp.net. The excel file would need to be uploaded to the server from a web page first, before the loaded...
3
by: NEWSGROUPS | last post by:
I am in the midst of trying to convert about 25 Access 2000 to Access 2003. The new environment consists of Office/Access 2003 and Outlook 2003. When converting the back ends I have no problems....
4
by: wellscrambled | last post by:
Folks, Probably don't have the right forum here, but this is all a bit new to me. I have a web site that sends me a daily email with an excel spreadsheet attachment that contains some customer...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.