Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6903549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:56:22+00:00 2026-05-27T07:56:22+00:00

When I add a value to my SqlDataRecord some how it is round the

  • 0

When I add a value to my SqlDataRecord some how it is round the value. I am not sure what is causing it.

EDIT: John made a good point Left out the property type for dm which is “decimal?”

TotalCount = 2.5245332200983

SqlDataRecord rec = new SqlDataRecord(
                new SqlMetaData("TotalCount", SqlDbType.Decimal));

rec.SetNullableDecimal(0,dm.TotalCount);

When it is written to the DB it is showing 3.0000000000000

Database Type added so I can pass a TVP:

CREATE TYPE dbo.TestCount AS TABLE(
TotalCounts decimal(38,20) NULL
);

Database Table:

CREATE TABLE dbo.TestCountTbl(
TotalCounts                 decimal(38,20) NULL);

What am I doing wrong? Is the SqlDbType wrong?

EDIT: Per @user957902 I had to add precision / scale to my SqlDataRecord….totally makes sense…duh. So I added that and works like a charm. Thanks All!

SqlDataRecord rec = new SqlDataRecord(
                new SqlMetaData("TotalCount", SqlDbType.Decimal,38,20));
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:56:22+00:00Added an answer on May 27, 2026 at 7:56 am

    According to the documentation for the SqlMetaData constructor you are using here, for SqlDbType.Decimal, the default for Precision is 18 and for scale is 0. So by default its not going to store anything past the decimal. You will need to use the constructor that allows you to set precision and scale descibed here.

    public SqlMetaData(
        string name,
        SqlDbType dbType,
        byte precision,
        byte scale
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to add value from devise registration form to another table that is not
While trying to add value into foreign key field, if same data doesn't exist
I am trying to add value to CoreData from .plist and get from coreData
How to add value to this form.content before rendering class myform(forms.Form): title = forms.CharField(max_length
How can I add key value pairs to an array? This won't work: public
Now I can add single value or tubles to the pipeline, my next question
I need to add default value column in SqlServer Compact....i am new to this
How would I add key value pairs to the body of a NSMutableURLRequest? I
I am trying to add the value of each bar to my bargraph. I'd
I'm trying to add a value (in this case the string I Added This)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.