locked
could not be set to a ‘Int16′ value. - Issue RRS feed

Answers

  • Hi SSAshok;

    Did you set the column in the model to a data type of System.Int16? According to Microsoft setting a database column to smallint the CLR type that will NOT cause an overflow or data loss needs to be System.Int16, please see the chart on this page.

    SQL-CLR Type Mapping

      


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    Tuesday, August 21, 2012 2:37 PM

All replies

  • Hi SSAshok;

    Did you set the column in the model to a data type of System.Int16? According to Microsoft setting a database column to smallint the CLR type that will NOT cause an overflow or data loss needs to be System.Int16, please see the chart on this page.

    SQL-CLR Type Mapping

      


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    Tuesday, August 21, 2012 2:37 PM
  • Thanks Fernando....We have a model data type of boolean for smallint DB datatype. Is this a root cause for the random issue that we are facing? Even if the "boolean->smallint" mapping is wrong, we are still wondering why it is happening randomly? Thanks for your help.
    Tuesday, August 21, 2012 3:07 PM
  •   

    According to the Microsoft documentation I gave in my last post setting a database column to smallint mapping it to a CLR type Boolean can cause this, "Possible overflow/data loss exception getting data from the database", so will this happen every time most likely not, will it happen randomly most likely depending on the data values.

      


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    Tuesday, August 21, 2012 3:28 PM
  • Thanks Fenando. We always pass "true", "false" and null values. It works most of the time. We might get this error due to data loss as you said. We will change our code and update you how it goes in our production.

    Tuesday, August 21, 2012 3:34 PM