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

  • Home
  • SEARCH
  • 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 8088395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:04:38+00:00 2026-06-05T19:04:38+00:00

I have a column type money in my sql server database, which is moneyAcumulated

  • 0

I have a column type money in my sql server database, which is moneyAcumulated. Then with a command object I execute a store procedure that -among others things- brings the value for the column moneyAcumulated. Then in the while loop I store in variables all the values for each column the store procedure returns.

SqlCommand command = new SqlCommand("getTickets", Connection.getConnection());
            command.CommandType = CommandType.StoredProcedure;

            SqlDataReader reader = command.ExecuteReader();

            string bet = "";
            decimal moneyAcumulated = 0.0M;
            string id= "";
            string name = "";
            int cod = -1;
            decimal prize = 0.0M;
            while (reader.Read())
            {
                bet = reader.GetString(0);
                moneyAcumulated = reader.GetDecimal(1); // This variable doesn't chage its value
                name = reader.GetString(2);
                id = reader.GetString(3);
                cod = reader.GetInt32(4);
            }

First time while loop iterates each variable takes the correct value (including moneyAcumulated that brings the reader, but second time moneyAcumulated doesn’t change its value and the others do, why?

  • 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-06-05T19:04:40+00:00Added an answer on June 5, 2026 at 7:04 pm

    The problem is that the SqlDataReader load all the data returned by the command.ExecuteReader in memory then if the data changes in the database, they would not change in the memory, I thought they would change every time the program execute the reader.Read() method, so that’s why is was not working. And as the moneyAcumulated field in database is the same initially for all the tuples that confused me more, because the others were changing while moneyAcumulated wasn’t.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have SQL Server 2000 database with money data type columns and we have
I have an int(11) column which is used to store money. I read some
I have a table called users which currently contains column money of type integer
I have a byte column called 'Type' in my MS Server database. On my
I'm using MS SQL Server 2008. I have a column of type XML that
In database table I have column called options . It has type of integer
I have a column in my datatable which is of DateTime Type. I only
I have a column in a PostgreSql database that is defined with type boolean[]
I've got a column in my Microsoft SQL CE 3.5 SP2 database called Type
I basically have a Money value type, which consists of Amount and Currency .

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.