type conversion issue.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ashish

    #1

    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.Execu teScalar(.....) , throws an error

    while

    decimal d = (decimal) DataStore.Execu teScalar(.....) , works fine ....


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


    regards
    -ashish
  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: type conversion issue.

    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]
    - mvp@spam.guard. caspershouse.co m

    "Ashish" <asharma@thisis junk.com> wrote in message
    news:OEBMhWPAGH A.532@TK2MSFTNG P15.phx.gbl...[color=blue]
    > 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.Execu teScalar(.....) , throws an error
    >
    > while
    >
    > decimal d = (decimal) DataStore.Execu teScalar(.....) , works fine ....
    >
    >
    > is this consistent, is there a ADO.Net conversion map somewhere for SQL
    > Server ?
    >
    >
    > regards
    > -ashish[/color]


    Comment

    • Ashish

      #3
      Re: type conversion issue.

      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:[color=blue]
      > Ashish,
      >
      > I don't know of where there is a map, but what is the type of your
      > identity field in SQL?
      >
      >[/color]

      Comment

      • Ashish

        #4
        Re: type conversion issue.

        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:[color=blue]
        > Ashish,
        >
        > I don't know of where there is a map, but what is the type of your
        > identity field in SQL?
        >
        >[/color]

        Comment

        Working...