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.