You must Sign In to post a response.
  • Category: ASP.NET

    Pass "1.0" from c# code to sql server

    I have to pass value "1.0" from c# code and store as 1.0 in sql.

    If i keep String dataype it's storing as 1 in db

    If i keep decimal (5,2) datatype its throwing error 'cannot convert decimal to varchar'. NOTE: I have kept datatype as decimal in database as well as in c#

    Please do the needful
  • #769203
    its datatype issue, change the datatype to (18,6) or so, whichever is suitable for you,
    The second part of decimal data type shows how many digits do you require after the 'point'. In your case it's '0', so db is rounding it to nearest integer, Numeric data types that have fixed precision and scale. Decimal and numeric are synonyms and can be used interchangeably.
    for more details please switch to below URL

    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • Sign In to post your comments