C
C#11mo ago
Colito008

Need help to detect error in code for POS system

in the following code my method for updating qty in the Products table is not working:
14 Replies
friedice
friedice11mo ago
What's not working
Angius
Angius11mo ago
Describe "not working" Does it just not do anything? Does it insert the data into a wrong database? Does it explode your microwave?
Colito008
Colito00811mo ago
if (cancelOrder.cboInventory.Text == "yes" && cancelOrder.CancelQtyValue > 0) { dbcon.ExecuteQuery("UPDATE tbProduct SET qty = qty + " + cancelOrder.CancelQtyValue + " where pcode= '" + cancelOrder.txtPcode.Text + "'"); } this piece of code does not update to the products table
Angius
Angius11mo ago
Also, I hope it's not actually production code that some company runs, but rather a school homework or some such Because if not, that would mean your passwords are stored in plaintext
Colito008
Colito00811mo ago
nah its schoolwork
Angius
Angius11mo ago
Use a parametrized query
Colito008
Colito00811mo ago
honestly i have no idead what is that
Angius
Angius11mo ago
You do:
cm = new SqlCommand("Select * From tbUser Where username = @username and password = @password", cn);
cm.Parameters.AddWithValue("@username", txtUsername.Text);
cm.Parameters.AddWithValue("@password", txtPass.Text);
dr = cm.ExecuteReader();
cm = new SqlCommand("Select * From tbUser Where username = @username and password = @password", cn);
cm.Parameters.AddWithValue("@username", txtUsername.Text);
cm.Parameters.AddWithValue("@password", txtPass.Text);
dr = cm.ExecuteReader();
Already used it once
Colito008
Colito00811mo ago
to be more specific i have multiple forms of the app this is just one of them
Angius
Angius11mo ago
Then my advice is the same for all other forms Once everything... or, well, the most critical parts at least, is up to spec and things still don't work, that's when we can easily look for issues
Colito008
Colito00811mo ago
then what should i do then?
MODiX
MODiX11mo ago
Angius
Use a parametrized query
React with ❌ to remove this embed.
Colito008
Colito00811mo ago
would you believe me the error was on the if statement "if (cancelOrder.cboInventory.Text == "yes" && cancelOrder.CancelQtyValue > 0)" on the sense that the combo box had alternatives "Yes" and "No" so for the program it would allways be no cause of the uppercase kekw
SG97
SG9711mo ago
well, when
Want results from more Discord servers?
Add your server