Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 20 total
Thread Testing for invalid data
Wed, Nov 9 2011 10:37 AMPermanent Link

Mike Corrente

I have a table from a 3rd party that I'm trying to read.  I'm not sure how, but he has a DECIMAL column that contains an empty string in certain rows.  The problem is that I get the error "Input string was not in a correct format" whenever I try to read that column using datareader(columnindex).

If I use datareader.getvalue(columnindex), I get the same error.  However, knowing it's a string, I use datareader.getstring(columnindex) in my immediate window and it returns the empty string.  AFTER THAT, datareader.getvalue(columnindex) seems to work perfectly.

My problem is I have no idea how I'm supposed to retrieve this data.  The only reason I know to use datareader.getstring is that I open the table and see it's a string as opposed to dbnull.  Is there any way to determine the format of the data in the column independent of the column's specified datatype?
Wed, Nov 9 2011 10:58 AMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Mike,

The table might be corrupted.
Can you open it with DBSys ?

--
Fernando Dias
[Team Elevate]
Wed, Nov 9 2011 11:10 AMPermanent Link

Mike Corrente

Yes, just fine.  That's how I'm able to tell it's a string value.

It's apparently not a DECIMAL type column, but a BCD.  I'm not as familiar with BCD, so an empty string may be valid data for that datatype.  Regardless, still need to figure out how to handle it.
Wed, Nov 9 2011 11:24 AMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Mike,

The BCD type that you see in DBSys is the same as the SQL DECIMAL type, and no, string values can't be stored in a BCD / DECIMAL column. Thats why i suspect it might be corrupted.
If you can open it with DBSys you can also Verify and Repair the table.
You can verify the table opening DBSys and then choose "Utilities" in the main menu and then "Verify Table...". I recommend you to make a backup of the original table before repairing, just in case Smiley

--
Fernando Dias
[Team Elevate]
Wed, Nov 9 2011 11:47 AMPermanent Link

Mike Corrente

Repaired successfully, nothing in repair log (other than repair start a complete messages).  Getting the same error.
Wed, Nov 9 2011 11:51 AMPermanent Link

Mike Corrente

Verified as well.  Forgot to mention that.
Wed, Nov 9 2011 12:01 PMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Mike,

Can you post the table in binaries or send it to me?
Also, what version of DBISAM are you using?

--
Fernando Dias
[Team Elevate]
Wed, Nov 9 2011 12:08 PMPermanent Link

Mike Corrente

Table attached.

I'm using both 3 and 4 - the 3rd party program that generates the tables has some legacy tables in 3 and new settings tables in 4, so my code is using whatever's appropriate.  I believe all the 4 tables are post 4.27 (I know there was a compatibility issue with BLOB data between 4.27 and 4.28, but doubt that's relevant) so I'm using the 4.31 ODBC driver for ver. 4 tables.



Attachments: MTRegions4.zip
Wed, Nov 9 2011 1:22 PMPermanent Link

Mike Corrente

Not sure if this is relevant, but in the same database there's another table that has a smallint column.  When I open that table in DBSys, none of the records appear to have any data for that column.  When I open it using a datareader, there's data.

The really weird part is that the data seems to change.  I'm comparing a copy of the same table and getting different values.  For instance, I'll copy the DAT and IDX file of the current table to a subfolder then immediately open both the original and the copy in datareaders and compare the columns, and the first record always has a different value - only the first record.

That seems to be happening with several tables - whenever I make a copy the first record of the table has some columns (not all) that change without anyone touching them.  Not sure if that's related.
Wed, Nov 9 2011 1:33 PMPermanent Link

Raul

Team Elevate Team Elevate

Mike

Please do not attach files in main newsgroups - use the dedicated binary newsgroup for that.

Looking at your data it appears those values are simply NULL. If you run this query in DBSYS does it return the rows you're having problems with : "select * from MTRegions4 where AdminExpPercentage is NULL" ?

I have not used the datareader or odbc but generally you'd need to check for value being NULL before trying to read it.

Raul
Page 1 of 2Next Page »
Jump to Page:  1 2
Image