चूंकि आप @Price . को कोई मान नहीं दे रहे हैं सी# कोड . में जबकि आपका Warehouse Id और Discount rate एंड-यूज़र द्वारा असाइन किए जाने के अधीन हैं, मेरा सुझाव है कि आपका कोड इस तरह हो:
private void button4_Click(object sender, EventArgs e)
{
try
{
var discountRate = 0.07; //could be Convert.ToDouble(textBox1.Text) or something else
var warehouseId = 6; //again, could be Convert.ToInt32(textBox2.Text) or something else
myConnection = new SqlConnection(frm.cs);
myCommand = new SqlCommand("update Inventory set Price=Price*(example@sqldat.com) " +
"where example@sqldat.com", myConnection);
myConnection.Open();
myCommand.Parameters.AddWithValue("@DiscountRate", discountRate);
myCommand.Parameters.AddWithValue("@WarehouseId", warehouseId);
myCommand.ExecuteNonQuery();
myConnection.Close();
MessageBox.Show("Update successfully!");
DisplayData();
if (myConnection.State == ConnectionState.Open)
{
myConnection.Dispose();
}
}
catch
{
}
}
मैं आपको अपनी क्वेरी के बारे में फिर से सोचने की सलाह दूंगा क्योंकि यह सभी उत्पादों की कीमतों को एक ही मूल्य के साथ अपडेट करेगा, आप पैरामीटर पास करने पर विचार कर सकते हैं @ProductId और आपकी क्वेरी हो
update Inventory set Price=Price*(example@sqldat.com)
where example@sqldat.com and example@sqldat.com
यकीन है कि उदाहरण के लिए था।