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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:51:05+00:00 2026-05-26T10:51:05+00:00

I am calling a static function to replace a value in .accdb file; to

  • 0

I am calling a static function to replace a value in .accdb file; to find a value of oldOA, then replace it with newOA.

    public static bool updateOA(string oldOA, string newOA)
    {
        ...
        command.Parameters.AddWithValue("@oldOA", oldOA);
        command.Parameters.AddWithValue("@newOA", newOA);

        command.CommandText = "SELECT [OA_ID] FROM [Operating_Authority_Table] WHERE [OA_Name] = [@oldOA]";
        long value = long.Parse(command.ExecuteScalar().ToString());
        command.Parameters.AddWithValue("@OA_ID", value);

        command.CommandText = "UPDATE [Operating_Authority_Table] SET [OA_Name] = [@newOA] WHERE [OA_ID] = " + value;

        try
        {
            command.ExecuteNonQuery();
            message.show(1, "", "true");
            
            return true;
        }
        catch
        {
            message.show(1, "", "false");
            return false;
        }
    }

Initially i simply used:

    command.CommandText = "UPDATE [OA_Table] SET [OA_Name] = [@newOA] WHERE [OA_Name] = [@oldOA]";

But i was told that I should get the OA_ID, which is the PK and update it from there, there resulting in the above code, but although the function still returns true, the value in the database still isn’t updated..

EDIT

command.CommandText = "UPDATE [Operating_Authority_Table] SET [OA_Name] = @newOA WHERE [OA_Name] = @oldOA";

I updated to this statement already, though it still returns true, the value does not get updated. Am i making any syntax mistakes?

  • 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-26T10:51:05+00:00Added an answer on May 26, 2026 at 10:51 am
    update Operating_Authority_Table set OA_Name = @newOA where OA_ID = (select OA_ID from Operating_Authority_Table where OA_Name = @oldOA) 
    

    My guess is this can solve your problem

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

Sidebar

Related Questions

private static void deleteProxy(File proxyOld, String host, int port) { try { String lines,
I have this fetch function: public static function fetch($class, $key) { try { $obj
Consider the TranslateAllCoords static function: static class CoordinateTransformation { public static void TranslateAllCoords(ref int
Consider this code : class App { public static function log($msg) { echo $msg;
I've got a problem when I'm calling a static var from another class. I
How could I go about calling a method on a static class given the
Calling Validate() on an XmlDocument requires passing in a ValidationEventHandler delegate. That event function
Using this function in my C# exe, I try to pass a Unicode string
I'm trying to call a function within a string return statement. Both are in
let's say i have a singleton object with a static function: static int MySingletonObject::getInt()

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.