I made my own SQL string that uses INNER JOINS. Here is my function:
string cmdstr = @"SELECT s.*, mdb.menu_name
FROM stocksdb s, recipelist rl
INNER JOIN menudb mdb ON rl.menu_ID = mdb.menu_ID
WHERE rl.stock_ID = '" + stockID + "'";
var cmd = new MySqlCommand(cmdstr, db.mycon);
var dr = cmd.ExecuteReader();
while (dr.Read())
{
var menuname = dr["menu_name"].ToString();
stockIDTxtbox.Text = stockID;
nameTxtBox.Text = dr["stock_name"].ToString();
availableTxtbox.Text = dr["stock_quantity"].ToString();
pricePerPieceTxtbox.Text = dr["stock_pricePerPiece"].ToString();
limitTxtBox.Text = dr["stock_limit"].ToString());
recipeList.Items.Add(new ListViewItem(new[] { menuname });
}
Now the problem is, when I click one Item on the stocksList ListView
the recipeList ListView
would have multiple values. Like 5 or so rows of the same values.
A join with stocksdb is missing. Something like this:
SELECT s.*, mdb.menu_name
FROM stocksdb s
INNRER JOIN recipelist rl
ON s.stock_ID= r1.stock_ID <== this join was missing
INNER JOIN menudb mdb
ON rl.menu_ID = mdb.menu_ID
WHERE rl.stock_ID = '" + stockID
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With