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 3480610
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:22:12+00:00 2026-05-18T10:22:12+00:00

I am trying to update a set of queries using .NET’s DataAdapter. Here’s a

  • 0

I am trying to update a set of queries using .NET’s DataAdapter. Here’s a simplified version of what I’m doing:

       //get all transactions that need to be made
        String sql = "SELECT r.ID, r.[Check], r.Cash, r.Coin, r.TenantID, t.TenantName, r.PropertyID, u.UnitNumber, r.ReceivedFrom, r.isDeposited FROM tblCashReceipts r " +   //I don't actually think all this is needed, if nessecary I can go back and remove unnessecary selections
            "LEFT JOIN tblTenant t " +
            "ON t.ID = r.TenantID " +
            "LEFT JOIN tblProperty p " +
            "ON p.ID = r.PropertyID " +
            "LEFT JOIN tblRentalUnit u " +
            "ON t.UnitID = u.id " +
            "WHERE p.CheckbookID = " + checkbookId;

        //populate the data table
        DataTable receipts = new DataTable();
        using (SqlConnection conn = new SqlConnection(connectionString)) {
            conn.Open();
            SqlDataAdapter adapter = new SqlDataAdapter(sql, conn);
            try {
                adapter.Fill(receipts);
            } catch (Exception ex) {
                MessageBox.Show(ex.Message);
            } finally {
                conn.Close();
            }
        }

        //update the row
        foreach (DataRow row in receipts.Rows) {
            //no longer removing, it will be left entact with the hidden tblCashReceipt row
            row["isDeposited"] = true;
        }

        //now make the database reflect our changes to the tblCashReceiptes
        using (SqlConnection conn = new SqlConnection(connectionString)) {
            SqlDataAdapter receiptsAdapter = new SqlDataAdapter("SELECT ID FROM tblCashReceipts", connectionString);
            //create delete command

            conn.Open();

            SqlCommand receiptsUpdateCommand = new SqlCommand("UPDATE tblCashReceipts SET isDeposited = @isDeposited WHERE ID = @ID", conn);

            SqlParameter idParam = receiptsUpdateCommand.Parameters.Add("@ID", SqlDbType.Int, 5, "ID");
            idParam.SourceVersion = DataRowVersion.Original;

            SqlParameter depositiedParam = receiptsUpdateCommand.Parameters.Add("@isDeposited", SqlDbType.Bit, 1, "isDeposited");
            depositiedParam.SourceVersion = DataRowVersion.Original;

            receiptsAdapter.UpdateCommand = receiptsUpdateCommand;
            receiptsAdapter.Update(receipts);
        }

However, I find that the receiptsAdapter.Update(receipts); doesn’t actually result in the database being updated. What am I doing wrong?

A simplified way of writing this would be just to execute the sql command of: UPDATE tblCashReceipts SET isDeposited = 1 WHERE {my clause} But I want to learn how to use ADO.NET stuff.

  • 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-18T10:22:13+00:00Added an answer on May 18, 2026 at 10:22 am

    below line is having problem

    depositiedParam.SourceVersion = DataRowVersion.Original;
    

    it must be

    depositiedParam.SourceVersion = DataRowVersion.Current;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to switch boolean field using the following hql: update Entity e set
I`m trying to update time in datetime field as UPDATE table_name SET col_name=to_DATE('04/02/2012 00:12:00','MM/DD/YYYY
I am trying to use this MySQL query: SET @a:=0; UPDATE tbl SET sortId=@a:=@a+1
I am trying to execute the following query. update share set holder = 22
Recently, I was trying to optimise this query UPDATE Analytics SET UserID = x.UserID
I am trying update my version of sqlite3 on mac os x 10.5.7 I
I am trying update text views while this loop is processing. Here is my
When trying to update a subversion working copy from Netbeans, I get the following
I'm using MS Access 2003 and I'm trying to execute a few queries at
I am trying to fire Update Query using cfquery like below <cfquery name =

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.