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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:11:53+00:00 2026-05-11T20:11:53+00:00

When several fields in a MSAccess table need to be updated (For instance Salary=Salary*Factor,

  • 0

When several fields in a MSAccess table need to be updated (For instance Salary=Salary*Factor, SomeNumber=GetMyBusinessRuleOn(SomeNumber) etc…),and the update should affect every record in a table, which technique would you use?

I have just started to implement this with DataSets, but got stuck (Updating and persisting dataset problem)

But maybe this isn’t even the ideal way to handle this kind of batch update?

Note : the updates don’t have to be on disconnected data first, so a dataset is not necessary.

UPDATE :

  • One command won’t do, I need some kind of recordset or cursor to cycle through the records
  • 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-11T20:11:53+00:00Added an answer on May 11, 2026 at 8:11 pm

    I would just use a ODBCConnection/ODBCCommand and use a SQL Update query.

    There is a JET Database driver that you should be able to use to establish a database connection to a MSAccess database using the ODBCConeection object.

    string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\\PathTo\\Your_Database_Name.mdb; User Id=admin; Password=";
    
    using (OdbcConnection connection = 
               new OdbcConnection(connectionString))
    {
        // Suppose you wanted to update the Salary column in a table
        // called Employees
        string sqlQuery = "UPDATE Employees SET Salary = Salary * Factor";
    
        OdbcCommand command = new OdbcCommand(sqlQuery, connection);
    
        try
        {
            connection.Open();
            command.ExecuteNonQuery();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
        // The connection is automatically closed when the
        // code exits the using block.
    }
    

    You could use these websites to help you generate a connection string:

    • http://www.connectionstrings.com/
    • http://www.sqlstrings.com/

    EDIT – Example for using a data reader to cycle through records in order to aply the business rule

    I should note that the following example could be improved in certain ways (especially if the database driver supports parameterized queries). I only wanted to give a relatively simple example to illustrate the concept.

    using (OdbcConnection connection = 
               new OdbcConnection(connectionString))
    {
        int someNumber;
        int employeeID;
        OdbcDataReader dr = null;
        OdbcCommand selCmd = new OdbcCommand("SELECT EmployeeID, SomeNumber FROM Employees", connection);
    
        OdbcCommand updateCmd = new OdbcCommand("", connection);
    
        try
        {
            connection.Open();
            dr = selCmd.ExecuteReader();
            while(dr.Read())
            {
                employeeID = (int)dr[0];
                someNumber = (int)dr[1];
                updateCmd.CommandText = "UPDATE Employees SET SomeNumber= " + GetBusinessRule(someNumber) + " WHERE employeeID = " + employeeID;
    
                updateCmd.ExecuteNonQuery();
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
        finally
        {
           // Don't forget to close the reader when we're done
           if(dr != null)
              dr.Close();
        }
        // The connection is automatically closed when the
        // code exits the using block.
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 108k
  • Answers 108k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try something like $('body').append("<div class='flora'></div>"); And if you really want… May 11, 2026 at 9:17 pm
  • Editorial Team
    Editorial Team added an answer reports_array_object = eval("(" + reports + ")"); sweet!!!! May 11, 2026 at 9:17 pm
  • Editorial Team
    Editorial Team added an answer It is a form of N-Tier Architecture. Initially, most sites… May 11, 2026 at 9:17 pm

Related Questions

I have a simple form on a view page, implemented as a user control,
I've been asked to make a small change to one of our RDLs. Essentially,
Somewhat related to my question about integers instead of decimals; my vendor provides a
I have an Address object that has properties AddressLine1, AddressLine2, Suburb, State, ZipCode. (there
In several web application projects I've been a part of, the client asks to

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.