Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO read Text File

Status
Not open for further replies.

marduk2002

Programmer
Apr 12, 2002
6
0
0
US
Hi,
I am using the code below to read a text file .
The problem is that field 40 contains
"5260318470123951"
However when this is read into the Recordset it is read in as
5.26031847012395E+15

Any Ideas on what is going on ?, I need the record to be read exactly as it is in the text file

Thanks


''''''''''code''''''''''''''''
Private Sub getrsValue()
Dim cnSample As New ADODB.Connection
Dim rsSample As New ADODB.Recordset

cnSample.Open "Driver={Microsoft Text Driver (*.txt; *.csv)};" _
& "Dbq= C:\;" _
& "Extensions=asc,csv,tab,txt;HDR=NO;" _
& "Persist Security Info=False"

rsSample.Open "Select * From Feed1.txt", cnSample, 3, 3, adCmdText
Do While rsSample.EOF <> True

MsgBox rsSample(40)
rsSample.MoveNext
Loop
End Sub
 
Are you sure it's being read in as 5.26031847012395E+15? Perhaps it's being read in correctly and VB is incorrectly converting to a numeric when you're displaying the value in your MsgBox call?? Try changing your code to
MsgBox rsSample(CSTR(40)) and see what happens.

 
Hi,
Yes i tried that and it still did not work.

If the number in the field has a length of 15 the number works fine, If the length is 16 or greater then it gets converted

Tnx for any help

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top