473,382 Members | 1,766 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,382 software developers and data experts.

A blank string instead of the actual number is returned when selecting from an Excell sheet.

Hi

I have an issue with an asp page that reads from an Excel file. I read the
file using OLEDB. I create a new Excel file using "MS Excel 2003" and put
the following data into a sheet called "Ark1" (2 columns and 5 rows):

1234 reer
1234 feb
4467 heerh
4467 123123
1122 234561122
Then I save the sheet and open an ASP page that has the following code:

Set conn = CreateObject("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strPath &
";Extended properties=""Excel 8.0;HDR=NO;"""
set rs = conn.Execute("Select * FROM [Ark1$]")
while not rs.eof
response.write("<br>" & rs(0) & " : " & rs(1))
rs.movenext
wend
And this is the result (with HTML code):
<br>1234 : reer<br>1234 : feb<br>4467 : heerh<br>4467 : <br>1122 :

If I replace <br> with a line-break, the result looks like this:
1234 : reer
1234 : feb
4467 : heerh
4467 :
1122 :
As you can see, las two iterations doesn't print the rs(1)) correctly.
Instead of printing the correct value, only a blank string is printed.
Initially I didn't make any formatting in the Excel sheet at all, but
formatting all columns in the sheet as "text" didn't help.

I've made several test files with random data in the two columns. It always
works fine when there is at least one none-digit character in the fields,
but when there are only numeric characters, it sometimes displays correctly,
and sometimes doesn't. The numbers in the first column also disappears
sometimes, it's not only the numbers in the second row.
Could you please help me with this issue? Thanks in advance.
Sep 23 '05 #1
3 4594
Hi Joakim,

Add IMEX=1 to your connection string so it looks like so:

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strPath & ";Extended
properties=""Excel 8.0;HDR=NO;"""

That tells ADO to just treat everything as text.

Ray at work
"Joakim Olesen" <jo*@logosconsult.dk> wrote in message
news:uW*************@tk2msftngp13.phx.gbl...
Hi

I have an issue with an asp page that reads from an Excel file. I read the
file using OLEDB. I create a new Excel file using "MS Excel 2003" and put
the following data into a sheet called "Ark1" (2 columns and 5 rows):

1234 reer
1234 feb
4467 heerh
4467 123123
1122 234561122
Then I save the sheet and open an ASP page that has the following code:

Set conn = CreateObject("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strPath &
";Extended properties=""Excel 8.0;HDR=NO;"""
set rs = conn.Execute("Select * FROM [Ark1$]")
while not rs.eof
response.write("<br>" & rs(0) & " : " & rs(1))
rs.movenext
wend
And this is the result (with HTML code):
<br>1234 : reer<br>1234 : feb<br>4467 : heerh<br>4467 : <br>1122 :

If I replace <br> with a line-break, the result looks like this:
1234 : reer
1234 : feb
4467 : heerh
4467 :
1122 :


Sep 23 '05 #2
Oops. I forgot to modify the connection string. 8|

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strPath & ";Extended
properties=""Excel 8.0;HDR=NO;IMEX=1"""

Ray at work

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:Oy**************@TK2MSFTNGP10.phx.gbl...
Hi Joakim,

Add IMEX=1 to your connection string so it looks like so:

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strPath & ";Extended
properties=""Excel 8.0;HDR=NO;"""

That tells ADO to just treat everything as text.

Ray at work
"Joakim Olesen" <jo*@logosconsult.dk> wrote in message
news:uW*************@tk2msftngp13.phx.gbl...
Hi

I have an issue with an asp page that reads from an Excel file. I read
the file using OLEDB. I create a new Excel file using "MS Excel 2003" and
put the following data into a sheet called "Ark1" (2 columns and 5 rows):

1234 reer
1234 feb
4467 heerh
4467 123123
1122 234561122
Then I save the sheet and open an ASP page that has the following code:

Sep 23 '05 #3
That seems to have solved my issue. I'm very glad that you helped me!
"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> skrev i en
meddelelse news:u9*************@tk2msftngp13.phx.gbl...
Oops. I forgot to modify the connection string. 8|

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strPath & ";Extended
properties=""Excel 8.0;HDR=NO;IMEX=1"""

Ray at work

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:Oy**************@TK2MSFTNGP10.phx.gbl...
Hi Joakim,

Add IMEX=1 to your connection string so it looks like so:

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strPath & ";Extended
properties=""Excel 8.0;HDR=NO;"""

That tells ADO to just treat everything as text.

Ray at work
"Joakim Olesen" <jo*@logosconsult.dk> wrote in message
news:uW*************@tk2msftngp13.phx.gbl...
Hi

I have an issue with an asp page that reads from an Excel file. I read
the file using OLEDB. I create a new Excel file using "MS Excel 2003"
and put the following data into a sheet called "Ark1" (2 columns and 5
rows):

1234 reer
1234 feb
4467 heerh
4467 123123
1122 234561122
Then I save the sheet and open an ASP page that has the following code:


Sep 25 '05 #4

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

Similar topics

1
by: Mustafa | last post by:
I have an ASP script where i am generating the excell sheet dynamically i am passing some column header text which is long text so i want it to display it vertically in column (cell).In excell i...
5
by: ChadDiesel | last post by:
My basic question is why does my print report button on my subform print a blank report when my cursor is on a blank entry line? Here is a more detailed explanation of my problem. I have a...
9
by: Hi5 | last post by:
Hi, I have designed a databasewhich is now able to store all data from my client's Excel sheet.Now I am looking for a good way to move their data into this Db. If I want to do this myself will...
32
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if...
3
by: Dan | last post by:
I'm writing a record from an asp.net page to SQL Server. After the insert I'm selecting @@identity to return the ID of the record that I just wrote. It worked fine until I typed a semicolon into...
2
seshu
by: seshu | last post by:
hi every body This is seshu i have doubt in mysql i have some date in excell sheet to export that data i have copied all the data into a text file and the wrote this code in...
19
by: billa856 | last post by:
Hi, I have to use the table(PRODUCTION) already generated in MS Access in which all fields are of TEXT type.fields like (orderdate,palletno,customercode,itemno,pono,carto n,pcs,totalquantity)Now i...
1
Ali Rizwan
by: Ali Rizwan | last post by:
Hi all, I m creating a database. The data for database will fetched from an excell sheet. Now how can i read an excell sheet and update my database with that excell sheet. Or I want to show...
3
by: ashokd001 | last post by:
Hi, How do i read time field from excell sheet by python. I am getting "0.400694444444" value but sheet has "9:37:00 AM" . How to convert it ? Regards, Ashok
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.