calculated data fields could not be converted

  • Thread starter Thread starter Mr. x
  • Start date Start date
M

Mr. x

Hello,

I use web-service, and also access for my database, and VB as my script of
web-service, and oleDBConnection to connect to database.

When I do query like this :
"select col1, col2, col3, ... from myTable"
....
mark = dr.getInteger(0) ' dr is the data-reader component.
....
.... everything works fine,

but when I do a query as follows :
"select col1 + 10, col2, col3, ... from myTable"
....
mark = dr.getInteger(0) ' dr is the data-reader component.
....
.... and trying running the query I get the following message :

'The data value could not be converted for reasons other than sign mismatch
or data overflow. For example, the data was corrupted in the data store but
the row was still retrievable".

What should I do in order to make things work on calculated fields ?

Thanks :)
 
Mr. x:

What is the datatype of Column1? Also, where are you getting the exception
thrown, on the line with mark = dr.GetInteger(0) or on executeReader? I'm
guessing it's numeric based on the first snippet but it may be trying to
concatenate 10 with the field.

Can you add 10 to the field like this?
mark = dr.getInteger(0) + 10;

Since it's a DataReader, you can't use an expression column like a
datatable, but if you are getting an int value (which getInteger is
ensuring) you should be able to do this. I've tried it even using null
values and haven't had a problem. The only other thing I can think of is if
your int value that you are referencing + 10 is greater than the value an
int can hold.

If it's failing on the Dr.Read though, then it's most likely something with
the syntax.

Let me know and hopefully we can figure it out.

HTH,

Bill
 
.... Thanks...

I think I have managed.
things work properly unless I use "+10" (or something else that is
calculation).

What I did (and I don't know if it is the best thing to do) is instead of
"getInteger()" I have used "getValue()", which finally didn't throw any
exception at all.

Thanks anyway :)
 
Back
Top