Datareader type conversion

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
 
V

Vadim Chekan

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

Vadim.
 
J

John Dann

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
 
J

John Dann

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
 
S

Steve Willcock

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

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

John Dann

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top