We help IT Professionals succeed at work.
Get Started

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

102 Views
Last Modified: 2020-01-31
Hi,
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.

G
Comment
Watch Question
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 19 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant

An Experts Exchange subscription includes unlimited access to online courses.

Get Started
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE