471,337 Members | 860 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

type conversion issue.

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
Dec 14 '05 #1
3 1521
Ashish,

I don't know of where there is a map, but what is the type of your
identity field in SQL?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Ashish" <as*****@thisisjunk.com> wrote in message
news:OE*************@TK2MSFTNGP15.phx.gbl...
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

Dec 14 '05 #2
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

Nicholas Paldino [.NET/C# MVP] wrote:
Ashish,

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

Dec 14 '05 #3
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



Nicholas Paldino [.NET/C# MVP] wrote:
Ashish,

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

Dec 14 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

17 posts views Thread by Sean Ross | last post: by
21 posts views Thread by Nitin Bhardwaj | last post: by
19 posts views Thread by Randy Yates | last post: by
7 posts views Thread by Ben R. | last post: by
4 posts views Thread by ranjeet.gupta | last post: by
1 post views Thread by jschon | last post: by
8 posts views Thread by ma740988 | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.