❔ many to many database cant update the 3rd table

HHercules_x_x12/10/2022
cant update the 3rd table who had the cust id and drink id
ImageImageImage
AAngius12/10/2022
You're not doing any updating in those screenshots, so that's probably why nothing gets updated
HHercules_x_x12/10/2022
i already did but when i take the screen shot i was empety
AAngius12/10/2022
Well, I can't see how you're doing the update
AAngius12/10/2022
I can't see any errors
AAngius12/10/2022
Any code that does (or doesn't do) what you think it does
HHercules_x_x12/10/2022
wait i will update now
AAngius12/10/2022
It's like going to the doctor, saying "me hurt but I have good eyesight"
AAngius12/10/2022
Zero information besides unrelated one
HHercules_x_x12/10/2022
ImageImageImage
HHercules_x_x12/10/2022
u see
HHercules_x_x12/10/2022
the many to many table stay empty
HHercules_x_x12/10/2022
the third one
AAngius12/10/2022
That's still a bunch of selects
AAngius12/10/2022
How are you updating the data?
AAngius12/10/2022
How are you inserting it?
AAngius12/10/2022
With EF Core?
AAngius12/10/2022
With raw SQL?
AAngius12/10/2022
With NHibernate?
AAngius12/10/2022
With a sproc?
HHercules_x_x12/10/2022
wuth visual studio
AAngius12/10/2022
Show me the code you use to update the data
HHercules_x_x12/10/2022
private void buttonSubmit_Click(object sender, EventArgs e)
{
string Gender = ""; MySqlCommand command1, command2; string value1 = "", value2 = "";

if (radioButtonMale.Checked) { Gender = "Male"; } else { Gender = "Female"; }
try
{
conn.Open();
MySqlCommand cmd1 = new MySqlCommand("Insert into customer(Name,Gender,Age,PhoneNo) values('" + textBoxName.Text + "','" + Gender + "','" + textBoxAge.Text + "','" + textBoxPhone_No.Text + "');", conn);
MySqlCommand cmd2 = new MySqlCommand("Insert into drink(Drink_Option,Price) values('" + this.comboBoxDrink_Option.SelectedItem.ToString() + "','Rm3.50')", conn);

string sql_Customer = "selectfrom customer order by customer_ID";
command1 = new MySqlCommand(sql_Customer, conn);
MySqlDataReader reader1 = command1.ExecuteReader();

cmd1.ExecuteNonQuery();
cmd2.ExecuteNonQuery();
/
cmd3.ExecuteNonQuery();*/
MessageBox.Show("Thank you for your feedback (◎≧v≦)人(≧v≦●))");
conn.Close();
}
catch (MySqlException ex)
{
MessageBox.Show(ex.Message);
}
}
AAngius12/10/2022
Any exceptions thrown?
HHercules_x_x12/10/2022
i dont understand
HHercules_x_x12/10/2022
this all under the sumbet button
AAngius12/10/2022
When you submit the form or whatever, do you get any error?
HHercules_x_x12/10/2022
no
HHercules_x_x12/10/2022
no errors
AAngius12/10/2022
My bet would be that string concatenation somehow makes the query malformed
AAngius12/10/2022
I'd use parametrized queries instead
HHercules_x_x12/10/2022
how to chamge to parameterz they didnt teach us
HHercules_x_x12/10/2022
would help a lot if u guid lol
HHercules_x_x12/10/2022
guide me
HHercules_x_x12/10/2022
i am lost...
HHercules_x_x12/10/2022
what part is need to change in my code
HHercules_x_x12/10/2022
to be parameterd
AAngius12/10/2022
Instead of string concatenation, use the @ parameter names
AAngius12/10/2022
Then, bind the parameters with query.Parameters.AddWithValue()
HHercules_x_x12/10/2022
i know u dont want spone feed me but can at least change some of my cod so i understand
AAngius12/10/2022
var command = new MySqlCommand("INSERT INTO things (name, count) VALUES (@name, @count)");
command.Parameters.AddWithValue("@name", name);
command.Parameters.AddWithValue("@count", count);
command.ExecuteNonQuery();
AAngius12/10/2022
Here's a more clear example
HHercules_x_x12/10/2022
so will that fix the third table issue
HHercules_x_x12/10/2022
?
AAngius12/10/2022
It might
HHercules_x_x12/10/2022
any other possbilty
AAngius12/10/2022
I don't have any other ideas, no
HHercules_x_x12/10/2022
the main issue they didnt teach this
HHercules_x_x12/10/2022
and i feel u talk like something so hard to understand to be honest
AAccord12/11/2022
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
HHercules_x_x12/12/2022
thats th solutions
HHercules_x_x12/12/2022
n to a an extra connecton for the table
HHercules_x_x12/12/2022
for the third table