此查詢查找的庫存情況和標籤打印出來的樣子..顯示,如果查詢消息框= 0
{
string selection_price = DdPetPist.SelectedValue;
string selection_stock = DdPetPist.SelectedValue;
string petPrice = string.Empty;
string available = string.Empty;
{
MySqlCommand cd_price = new MySqlCommand(String.Format("SELECT Price FROM Animals WHERE Specie ='{1}' and Country ='{0}'", ddlcountry.SelectedItem.ToString().Trim(), selection_price), cs);
MySqlCommand cd_available = new MySqlCommand(String.Format("SELECT Stock FROM Animals WHERE Specie ='{1}' and Country ='{0}'", ddlcountry.SelectedItem.ToString().Trim(), selection_stock), cs);
cs.Open();
petPrice = Convert.ToString(cd_price.ExecuteScalar());
available = Convert.ToString(cd_available.ExecuteScalar());
cs.Close();
}
PetPrice.Text = String.Format("Minimum Donation For A {0} Is £{1}.", selection_price, petPrice);
Availble.Text = String.Format("{0}'s Avalible {1} In Your Country.", selection_stock, available);
}
怎樣纔可以有一個消息框彈出,如果stock
是= 0 ?
UPDATE
行,所以我將解釋什麼,我試圖做
我有一個UPDATE
查詢,將通過1每次按鈕被點擊時遞減的股票。查詢低於:
var myquery = string.Format("UPDATE Animals SET Stock = Stock - 1 WHERE Specie ='{1}'
and Country ='{0}' and Stock >0", ddlcountry.SelectedItem.ToString().Trim(),
selection_price);
現在我想的是,如果stock
是= 0的消息或警報彈出說選擇脫銷。
更新問題,包括更多的代碼。 – Beep
在應用遞減之前,您需要從數據庫中讀取數據,因爲查詢在完全不同的作用域上運行(數據庫引擎) – leon
Ok @Leon因此首先運行查詢? – Beep