troubleshooting Question

How can I dynamically change all the Names in one column ,  throughout a Table?

Avatar of G F
G FFlag for Canada asked on
C#SQL* MariaDB* visual studio 2019
19 Comments1 Solution110 ViewsLast Modified:
I'm looking for some help on a MariaDB (MySQL) project using c#.

I have two tables, one Customers (ID, Name, Email, etc), the other Agreements (ID, Customer Name, AgreementName, ExpiryDate).

My code works pretty good, I have a listbox that loads, and when the end user picks a customer from it, several text boxes populate the info where Customer records can be acted upon (changed, deleted etc).

Also, a second table is automatically accessed, keying off of the customers name selected from the first listbox, this displays all that customers agreements, if any, in a listView.
Everything works great, until I change/update the name of the customer.  The change goes through just fine on the first table, but then the second table loses the references because the name has changed.

If I change the name back, everything is fixed.

So I need a way to change all the names in the second table to the proper values and there can be 0 changes (no agreements), or hundreds of agreements.  In other words, some customers are not in the second table at all, and other customers are there hundreds of times.

So just wondering do I just need to get my second UPDATE statement correct?
I know there are Join (inner, outer ) but I'm not sure how to use them properly.

Here is my first SQL statement that updates the original customer record (this is working great):

 string Query = "update bbb.jurisdiction set JurName='" + this.jurTxtBoxName.Text + "',JurNumber='" + this.jurTxtBoxNumber.Text + "',JurContactPhoneNumber='" + this.jurTxtBoxContactnumber.Text + "',JurEmail='" + this.jurTxtBoxEmail.Text + "',JurWebsite='" + this.jurTxtBoxWebsite.Text + "',JurNotes='" + this.jurTxtBoxNotes.Text + "' where id='" + this.jurTextBoxID.Text + "' ; ";

And here is the SQL statement where I try and update the second table (does not work at all, but no error in code, or run time errors):

string Query2 = "update bbb.jurisdictionrua set JName='" + this.jurTxtBoxName.Text + "' where JName='" + this.jurTextBoxID.Text + "' ; ";

JName is the name of Column where the Customers Name is, that I need to change throughout the table.

So any help would be appreciated.

Thank you in Advance.

Join our community to see this answer!
Unlock 1 Answer and 19 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 19 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros