Datareader type conversion

  • Thread starter Thread starter John Dann
  • Start date Start date
J

John Dann

I have some data stored in a column of Int16 type (for compactness
and convenience) in a Jet 4 database. I'd like to retrieve it into a
datareader converted to double type and divided by 10 to restore its
true value. Is this possible please (using VB.Net)?

So what I'd like to do is have a select string along the lines of:

SELECT CDbl(Col_A/10) SomeName, Col_B ...etc FROM etc

But if indeed this is a permitted process I can't find what the
correct syntax should be. Using the sort of example above just gives
me a missing operator error.

TIA
JGD
 
See CAST/CONVERT operator.
select CAST(col_a as float)/10 as SomeName,....

MAny thanks, but trying this I get teh following error

'IErrorInfo.GetDescription failed with E_FAIL(some hex number)'

This is under VB.Net accessing an Access database. Maybe the syntax
needs to be slightly different for this environment? (Using double in
place of float doesn't help.)

JGD
 
MAny thanks, but trying this I get teh following error

'IErrorInfo.GetDescription failed with E_FAIL(some hex number)'

This is under VB.Net accessing an Access database. Maybe the syntax
needs to be slightly different for this environment? (Using double in
place of float doesn't help.)

Anyone have any thoughts on this please - this particular problem is
really holding up progress with my current project and I've run out of
ideas.

TIA
JGD
 
Access actually uses vb style syntax for datatype conversions - try the
following syntax

SELECT col1, col2, col3, CDbl(Value) / 10 as DblValue
FROM TableName;
 
Access actually uses vb style syntax for datatype conversions - try the
following syntax

SELECT col1, col2, col3, CDbl(Value) / 10 as DblValue
FROM TableName;

Great - many thanks. Funny how easy it is sometimes to expect
complications and to overlook the simple obvious options.

JGD
 
Back
Top