number to string

A

atse

Hi,

When I select a filed from a txt or csv file, and display on the ASP, the 16
digit of barcode number (9876543210123456) becomes to 9.87654321012345E+15.
How can I make it display the original. Thanks

Atse
 
A

atse

the source code
<%
' pass the filename of a file located in C:\upload\
file=Request.QueryString("file")

con_xls="Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\upload\\test.xls;Extended
Properties=""Excel 8.0;HDR=Yes;IMEX=1"""
set conn=server.CreateObject("ADODB.Connection")
conn.open(con_xls)

set rs = conn.execute ("select * from " & file)

%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<table border=1>
<%
if not rs.eof then
%>
<% do until rs.EOF %>
<tr>
<%
' there are 16 columns in this file, but I don't know how to define a
variable of the number of columns

for i =0 to 15
%>
<td> <%= rs(i)%> </td>
<%next%>
</tr>
<% rs.MoveNext
loop

end if
%>
</table>
</BODY>
</HTML>
 
R

Ray at

It seems to me that the only way that you can get this to display directly
from the RS the way you want is if you format the cell in Excel to display
the number as text.

Ray at home
 
A

atse

I am now trying insert the csv file into the database, and I set this field
as VARCHAR with length = 50
but 9876543210123456 in the original file still displays
9.87654321012345E+15 in the database, ASP,and the exported csv file.
Any idea to solve this problem

atse
 
R

Ray at

What does it look like in the CSV file when you look at it in a text editor,
such as notepad?

Ray at home
 
A

atse

The original one in Notepad is OK: 9876543210123456
after inserted into the database, it looks like 9.87654321012345E+15 (I can
view the record of database)

The exported csv file in Notepad and Excel looks like 9.87654321012345E+15
 
M

Mark Schupp

I came in late on this thread. What tool are you using to import the
original CSV?

If you are opening it with the MS Text drivers as a database you will need
to include a column definition INI file to tell the drivers that the column
is character data and not numeric (it should also be enclosed in quotes in
the CSV file). Unfortunately I cannot remember the name that the INI file
must use. Search through the documentation at Microsoft for the text
drivers.
 
A

atse

' The text driver is:
con_csv="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\mypath\;Extended
Properties=""text;HDR=No;FMT=Delimited"""
set conn=server.CreateObject("ADODB.Connection")
conn.open(con_csv)

' Because this is a csv file, I can only make a query string:
set Rs=conn.execute("select * from thisfile.csv")

' Then I run a script to insert these records into the database.
Unfortunately when this long number is inserted into the database, it
changes to another format as text. How can I make this long number as text
when inserting into the db? Thanks

Atse
 
M

Mark Schupp

There is a specially formatted INI file that you need to include in the same
directory as the CSV file to tell the Jet text driver that the column in
question is String instead of numeric. By default, the text driver "guesses"
the data type based on the "typical" contents of the column. I cannot
remember the name of the INI file but you should be able to find it in the
Microsoft documentation for the desktop drivers (I have to search for it
every time the subject comes up because I can never remember it).
 

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

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top