type conversion issue.

A

Ashish

its on .net 2.0

I am calling a stored procedure which returns value SCOPE_INDENTITY() ,
when i try to convert the result from object to int, it throws a type
conversion error...

after some hit and trials i figured out that the returned type is
actually decimal ..,
hence

int i = (int) DataStore.ExecuteScalar(.....) , throws an error

while

decimal d = (decimal) DataStore.ExecuteScalar(.....) , works fine ....


is this consistent, is there a ADO.Net conversion map somewhere for SQL
Server ?


regards
-ashish
 
N

Nicholas Paldino [.NET/C# MVP]

Ashish,

I don't know of where there is a map, but what is the type of your
identity field in SQL?
 
A

Ashish

the identity field is of type int, another point is that iam using Data
Application Block to access the and they are on 1.1, and my application
is on 2.0, can that cause a problem ?

regards
 
A

Ashish

Another point is that when i return

SELECT SCOPE_INDENTITY()

the type returned is System.Decimal

and when i return

SELECT uid FROM Addresses


Then the return value is System.Int32....

looks like sql_variant is being converted to decimal somehow ...

can someone confirm this ?


regards
 

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