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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:48:41+00:00 2026-06-11T16:48:41+00:00

I have a program that checks a table in an Access DB for 2

  • 0

I have a program that checks a table in an Access DB for 2 rows and allow the user to make changes to the ComplexityFactor column via textBox. If the rows do not exists when the application loads the 2 row are created (all the fields are the same except for the OHorUG field). Based on which row they have selected the user can then change the ComplexityFactor field of the selected row. I have been able to successfully create and read the rows but I cannot update the 1 field.

Here is the update code:

private void button1_Click(object sender, EventArgs e)
    {
        if (listView1.SelectedItems.Count != 0)
        {
            ListViewItem selected = listView1.SelectedItems[0];
            OleDbCommand updateCmd = new OleDbCommand();
            myConnection.Open();

            updateCmd.CommandType = CommandType.Text;
            updateCmd.CommandText = "UPDATE Contractors SET ComplexityFactor = @ComplexityFactor" +
               " WHERE Division = @Division AND ComplexityFactorCode = @ComplexityFactorCode AND ContractNumber = @ContractNumber AND ContractorCode = @ContractorCode AND ContractorName = @ContractorName AND OHorUG = @OHorUG)";

            updateCmd.Parameters.AddWithValue("@ComplexityFactor", textBox1.Text.ToString());//FYI this field is a Number in Access
            updateCmd.Parameters.AddWithValue("@Division", "SV");
            updateCmd.Parameters.AddWithValue("@ComplexityFactorCode", "X01");
            updateCmd.Parameters.AddWithValue("@ContractNumber", "0");
            updateCmd.Parameters.AddWithValue("@ContractorCode", "SSI");
            updateCmd.Parameters.AddWithValue("@ContractorName", "SunStream Inc");
            updateCmd.Parameters.AddWithValue("@OHorUG", selected.SubItems[6].Text.ToString());
            updateCmd.Connection = myConnection;
            updateCmd.ExecuteNonQuery();
            myConnection.Close();
        }
        else
        {
            MessageBox.Show("Please select a row to update...");


        }

I forgot to add the Exception:

System.Data.OleDb.OleDbException was unhandled
  Message=Extra ) in query expression 'Division = @Division AND ComplexityFactorCode = @ComplexityFactorCode AND ContractNumber = @ContractNumber AND ContractorCode = @ContractorCode AND ContractorName = @ContractorName AND OHorUG = @OHorUG)'.
  Source=Microsoft JET Database Engine
  ErrorCode=-2147217900
  StackTrace:
       at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
       at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
       at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
       at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
       at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
       at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
       at WindowsFormsApplication1.Form1.button1_Click(Object sender, EventArgs e) in c:\Users\s153720\AppData\Local\Temporary Projects\WindowsFormsApplication1\Form1.cs:line 199
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at WindowsFormsApplication1.Program.Main() in c:\Users\s153720\AppData\Local\Temporary Projects\WindowsFormsApplication1\Program.cs:line 18
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:     
  • 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-11T16:48:42+00:00Added an answer on June 11, 2026 at 4:48 pm

    Try and remove the closing bracket ) at the end of the update statement

    updateCmd.CommandText = "UPDATE Contractors SET ComplexityFactor = @ComplexityFactor" +
    " WHERE Division = @Division AND ComplexityFactorCode = @ComplexityFactorCode AND ContractNumber = @ContractNumber AND ContractorCode = @ContractorCode AND ContractorName = @ContractorName AND OHorUG = @OHorUG";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a VB6 program that adds a column to an MS Access database
I have a simple program that checks webpages for strings, example: Private Sub Button1_Click(ByVal
On my program I have a function that checks for the current version of
I have a program that stores user projects as databases. Naturally, the program should
In my program I have a table that, when loaded, has jQuery add some
I have a SQL Server table full of orders that my program needs to
I have a SQL Server DB table that has a column ReceivedDate defined as
I have to make a program that turns off all Unicode compression and all
I have a program that auto launches with Windows via scheduler. What it does
I have a listview that serves as a user-settings table. Each key is the

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.