Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / December 2005

Tip: Looking for answers? Try searching our database.

type conversion issue.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ashish - 14 Dec 2005 21:30 GMT
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
Nicholas Paldino [.NET/C# MVP] - 14 Dec 2005 21:34 GMT
Ashish,

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

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

> its on .net 2.0
>
[quoted text clipped - 17 lines]
> regards
> -ashish
Ashish - 14 Dec 2005 22:02 GMT
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

> Ashish,
>
>     I don't know of where there is a map, but what is the type of your
> identity field in SQL?
Ashish - 14 Dec 2005 22:37 GMT
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

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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.