❔ many to many database cant update the 3rd table

cant update the 3rd table who had the cust id and drink id
31 Replies
Angius
Angius2y ago
You're not doing any updating in those screenshots, so that's probably why nothing gets updated
hercules_x_x
hercules_x_xOP2y ago
i already did but when i take the screen shot i was empety
Angius
Angius2y ago
Well, I can't see how you're doing the update I can't see any errors Any code that does (or doesn't do) what you think it does
hercules_x_x
hercules_x_xOP2y ago
wait i will update now
Angius
Angius2y ago
It's like going to the doctor, saying "me hurt but I have good eyesight" Zero information besides unrelated one
hercules_x_x
hercules_x_xOP2y ago
hercules_x_x
hercules_x_xOP2y ago
u see the many to many table stay empty the third one
Angius
Angius2y ago
That's still a bunch of selects How are you updating the data? How are you inserting it? With EF Core? With raw SQL? With NHibernate? With a sproc?
hercules_x_x
hercules_x_xOP2y ago
wuth visual studio
Angius
Angius2y ago
Show me the code you use to update the data
hercules_x_x
hercules_x_xOP2y ago
BlazeBin - wkqsuzkalyeh
A tool for sharing your source code with the world!
hercules_x_x
hercules_x_xOP2y ago
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); } }
Angius
Angius2y ago
Any exceptions thrown?
hercules_x_x
hercules_x_xOP2y ago
i dont understand this all under the sumbet button
Angius
Angius2y ago
When you submit the form or whatever, do you get any error?
hercules_x_x
hercules_x_xOP2y ago
no no errors
Angius
Angius2y ago
My bet would be that string concatenation somehow makes the query malformed I'd use parametrized queries instead
hercules_x_x
hercules_x_xOP2y ago
how to chamge to parameterz they didnt teach us would help a lot if u guid lol guide me
Angius
Angius2y ago
Stack Overflow
Parameterized Query for MySQL with C#
I have the code below (I've included what I believe are all relevant sections): private String readCommand = "SELECT LEVEL FROM USERS WHERE VAL1 = ? AND VAL@ = ?;"; public bool read(string id) {...
hercules_x_x
hercules_x_xOP2y ago
i am lost... what part is need to change in my code to be parameterd
Angius
Angius2y ago
Instead of string concatenation, use the @ parameter names Then, bind the parameters with query.Parameters.AddWithValue()
hercules_x_x
hercules_x_xOP2y ago
i know u dont want spone feed me but can at least change some of my cod so i understand
Angius
Angius2y ago
var command = new MySqlCommand("INSERT INTO things (name, count) VALUES (@name, @count)");
command.Parameters.AddWithValue("@name", name);
command.Parameters.AddWithValue("@count", count);
command.ExecuteNonQuery();
var command = new MySqlCommand("INSERT INTO things (name, count) VALUES (@name, @count)");
command.Parameters.AddWithValue("@name", name);
command.Parameters.AddWithValue("@count", count);
command.ExecuteNonQuery();
Here's a more clear example
hercules_x_x
hercules_x_xOP2y ago
so will that fix the third table issue ?
Angius
Angius2y ago
It might
hercules_x_x
hercules_x_xOP2y ago
any other possbilty
Angius
Angius2y ago
I don't have any other ideas, no
hercules_x_x
hercules_x_xOP2y ago
the main issue they didnt teach this and i feel u talk like something so hard to understand to be honest
Accord
Accord2y ago
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.
hercules_x_x
hercules_x_xOP2y ago
BlazeBin - gpseforyplai
A tool for sharing your source code with the world!
hercules_x_x
hercules_x_xOP2y ago
thats th solutions n to a an extra connecton for the table for the third table
Want results from more Discord servers?
Add your server