C
C#12mo 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
friedice12mo ago
What's not working
Angius
Angius12mo 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
Colito008OP12mo 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
Angius12mo 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
Colito008OP12mo ago
nah its schoolwork
Angius
Angius12mo ago
Use a parametrized query
Colito008
Colito008OP12mo ago
honestly i have no idead what is that
Angius
Angius12mo 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
Colito008OP12mo ago
to be more specific i have multiple forms of the app this is just one of them
Angius
Angius12mo 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
Colito008OP12mo ago
then what should i do then?
MODiX
MODiX12mo ago
Angius
Use a parametrized query
React with ❌ to remove this embed.
Colito008
Colito008OP12mo 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
SG9712mo ago
well, when
Want results from more Discord servers?
Add your server