Adding '% into SQL Command
I have an SQL Query that i want to run throw my asp.net (WebForms) Project The Query is:
SELECT COUNT([order]) FROM menu_orders_Finished
WHERE [order] LIKE '%EXAMPLE%' What i'm trying to do is
con.Close();
con.Open();
cmd = new SqlCommand("select * from menu",con);
SqlDataReader dr;
dr = cmd.ExecuteReader();
Series series = Chart2.Series["Series2"];
while (dr.Read())
{
search = new SqlCommand("SELECT COUNT([order]) FROM menu_orders_Finished WHERE [order] LIKE '%@order@%'", con);
search.Parameters.AddWithValue("@order", dr["name"].ToString());
int count = Convert.ToInt32(search.ExecuteScalar());
Label3.Visible = true;
Label3.Text += count.ToString() + "+";
}
con.Close();Which is Basically Counting how many times i'm having an order with one my menu items in the order (I want to make a chart of the best selling meal)
And then adding it in the chart (But i toke it off just to see what i get first)
from Recent Questions - Stack Overflow https://ift.tt/3erlykX
https://ift.tt/eA8V8J
Comments
Post a Comment