I want to create a new variable using two string variables. But I keep getting the error message
"operator '-' cannot be applied to operands of type string and string c#".
string query3 = "SELECT Quantity FROM Supplier WHERE [Supplier ID]='"+supplierid+"'";
string query4 = "SELECT Quantity FROM Supplier WHERE [Book ID] = '" + bookid + "'";
SqlCommand cmd3 = new SqlCommand(query3, con);
SqlCommand cmd4 = new SqlCommand(query4, con);
con.Open();
string temporaryquantity = cmd3.ExecuteScalar().ToString();
string temporaryquantitystocks = cmd4.ExecuteScalar().ToString();
string totalcostforstocks = (temporaryquantitystocks-temporaryquantity + quantity) * buyingpriceperbook;
"quantity" is in int type
"buyingpriceperbook" is in double type
Can anyone help me with this?
ToStringit... You are trying to sum strings.+operator), but that concatenates them.