C
C#hercules_x_x

❔ many to many database cant update the 3rd table

cant update the 3rd table who had the cust id and drink id
A
Angius509d ago
You're not doing any updating in those screenshots, so that's probably why nothing gets updated
H
hercules_x_x509d ago
i already did but when i take the screen shot i was empety
A
Angius509d 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
H
hercules_x_x509d ago
wait i will update now
A
Angius509d ago
It's like going to the doctor, saying "me hurt but I have good eyesight" Zero information besides unrelated one
H
hercules_x_x509d ago
H
hercules_x_x509d ago
u see the many to many table stay empty the third one
A
Angius509d 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?
H
hercules_x_x509d ago
wuth visual studio
A
Angius509d ago
Show me the code you use to update the data
H
hercules_x_x509d ago
BlazeBin - wkqsuzkalyeh
A tool for sharing your source code with the world!
H
hercules_x_x509d 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); } }
A
Angius509d ago
Any exceptions thrown?
H
hercules_x_x509d ago
i dont understand this all under the sumbet button
A
Angius509d ago
When you submit the form or whatever, do you get any error?
H
hercules_x_x509d ago
no no errors
A
Angius509d ago
My bet would be that string concatenation somehow makes the query malformed I'd use parametrized queries instead
H
hercules_x_x509d ago
how to chamge to parameterz they didnt teach us would help a lot if u guid lol guide me
A
Angius509d 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) {...
H
hercules_x_x509d ago
i am lost... what part is need to change in my code to be parameterd
A
Angius509d ago
Instead of string concatenation, use the @ parameter names Then, bind the parameters with query.Parameters.AddWithValue()
H
hercules_x_x509d ago
i know u dont want spone feed me but can at least change some of my cod so i understand
A
Angius509d 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
H
hercules_x_x509d ago
so will that fix the third table issue ?
A
Angius509d ago
It might
H
hercules_x_x509d ago
any other possbilty
A
Angius509d ago
I don't have any other ideas, no
H
hercules_x_x509d ago
the main issue they didnt teach this and i feel u talk like something so hard to understand to be honest
A
Accord508d 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.
H
hercules_x_x507d ago
BlazeBin - gpseforyplai
A tool for sharing your source code with the world!
H
hercules_x_x507d 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
More Posts
✅ rest requests helphello i am trying to send to os command injections with RestSharp to dvwa for pentestering can someo❔ Source generator, generating type script definitions at compile timeI would like to make a automatic type script definition from code, i consider to use source generato❔ Making an async method without anything to async insidelet's say i have following scenario: ```csharp void Foo() { for(int i = 0 ; i < 10000000 ;i++){} /❔ Reading file from the folder where .csproj isHow can i read files from folder where .csproj is? just like webapps allow to do, they do not copy f✅ Interoperability between incompatible typesHi! I'm trying to pass a class back-and-forth from C# to CPP. This class contains some members that ❔ Set item to null inside a listHey! I am trying to remove some items from a JSON object (created like `var model = new ObjectModel{Refactoring long if statement that checks for user rolesHi, I'm trying to find a cleaner way of refactoring this if code block that checks for each user rol❔ IEnumerable and dependency injectionif i want to loop enumerable from DI multiple times ``` var foos = services.GetRequiredService<IEnum❔ How did you learn . NET ?Books /youtube/udemy /other courses, what resources made you learn .NET to use as your job as web de✅ Is it possible to disable these properties on EF6? Web API 2 project, multi-layered, NF472SCENARIO - Solution type is NET Framework 4.7.2 (it is, what it is). - I have this project, I'm cons✅ This EntityFramework query can not be translated for SQLiteThe issue lies within `Intersect`. The point of the query is to fetch the current user, and to popul✅ Detect Network RequestI want make service that detect all connection to specific domain or ip? And if this request contain❔ CORS errorHello, I have Cors error on my project. I add Addpolicy in my configureServices and also add app.Us❔ Ambiguities? How?Idk how i can resolve this i don't see the problem✅ How can I get rid of this annoying pointer thing in the first row, datagridview winforms^✅ How can I use a row header of a datagridview to display the row number instead of being empty?^✅ How can i properly display this datagridviewHow can i get rid of the row select thing on the left (just white space)✅ I am trying to output a 2D array to a datagridview, but it is not outputting correctlyIt is saying System.Int32[]✅ Task not returning and stopping programHey, I am currently trying to start one task for every string in the list, but this isn't working an❔ DbContextCan i use this in a non-asp area like for example, a simple program to make few tables using DbSet