❔ many to many database cant update the 3rd table
cant update the 3rd table who had the cust id and drink id
31 Replies
You're not doing any updating in those screenshots, so that's probably why nothing gets updated
i already did but when i take the screen shot i was empety
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
wait i will update now
It's like going to the doctor, saying "me hurt but I have good eyesight"
Zero information besides unrelated one
u see
the many to many table stay empty
the third one
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?
wuth visual studio
Show me the code you use to update the data
BlazeBin - wkqsuzkalyeh
A tool for sharing your source code with the world!
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); } }
cmd1.ExecuteNonQuery(); cmd2.ExecuteNonQuery(); /cmd3.ExecuteNonQuery();*/ MessageBox.Show("Thank you for your feedback (◎≧v≦)人(≧v≦●))"); conn.Close(); } catch (MySqlException ex) { MessageBox.Show(ex.Message); } }
Any exceptions thrown?
i dont understand
this all under the sumbet button
When you submit the form or whatever, do you get any error?
no
no errors
My bet would be that string concatenation somehow makes the query malformed
I'd use parametrized queries instead
how to chamge to parameterz they didnt teach us
would help a lot if u guid lol
guide me
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)
{...
i am lost...
what part is need to change in my code
to be parameterd
Instead of string concatenation, use the
@
parameter names
Then, bind the parameters with query.Parameters.AddWithValue()
i know u dont want spone feed me but can at least change some of my cod so i understand
Here's a more clear example
so will that fix the third table issue
?
It might
any other possbilty
I don't have any other ideas, no
the main issue they didnt teach this
and i feel u talk like something so hard to understand to be honest
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.BlazeBin - gpseforyplai
A tool for sharing your source code with the world!
thats th solutions
n to a an extra connecton for the table
for the third table