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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal Report: problem accessing table containing number and string

Status
Not open for further replies.

phkhong

Technical User
Jan 15, 2002
8
AU
I am developing a CR in VB and am having some problems accessing a table (in txt file format) where one of the column contain both numbers and string. See sample txt file below.

Sample txt file.txt
===================
Description, value
Item1, 123
Item2, 456
Item3, Text Description

The CR report I am designing is using unbound fields and both fields (Description and value) are string data type. The SQL query is "select * from file.txt".

When CR tries to access the table, it reported "Seagate Crystal Report: Database errors" with no message. When I clicked OK, the following message appears "Run-time error '-2147192185 (80047287)': SQL server error'. After some investigation, I came to the conclusion when CR is access the data, CR treated the first two as numbers and when reading the third line, found a mismatch and hence the error.

However, if I converted the file to the following, my CR report works like a charm.

Modified txt file.txt
=====================
Description, value
Item1, "123"
Item2, "456"
Item3, "Text Description"

I am trying to avoid adding the quotes in, can anyone provide some guidance how I can modify the query or CR?

PS: I have the totext function and it did not work.

 
It is not logical to use a field that contains different formats.But maybe this may work.Put a string variable at the beginning of your txt file such as

Description, value
Item3, "Text Description"
Item1, 123
Item2, 456

Then in my opinion,since the first record is string the following records will considered as string.
 
Thanks for your comments, I have tried your recommendation and also tried enclosing numbers with string as below but it did not work.

Description, value
Item3, "Text Description"
Item1, 123
Item2, 456
Item4, "Text Description"

Some clarification, I actually wanted all fields to be string (including the value column). Unfortunately, when saving a csv file from Excel, it will appear as a number and string.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top