c# asp.net problem with 'must declare the scalar variable'
- by Verian
I'm currently making a front end to display license information for my companies software audit but im no pro with sql or asp.net so iv ran into a bit of trouble. I'm trying to get a sum of how many licenses there are across several rows so i can put it in a text box, but im getting the error 'Must declare the scalar variable "@softwareID".'
SqlConnection con1 = Connect.GetSQLConnection();
string dataEntry = softwareInputTxt.Text;
string result;
dataEntry = dataEntry + "%";
con1.Open();
SqlCommand Mycmd1;
Mycmd1 = new SqlCommand("select sum(license_quantity_owned) from licenses where software_ID like @softwareID", con1);
MyCmd.Parameters.AddWithValue("@softwareID", dataEntry);
result = (string)Mycmd1.ExecuteScalar();
licenseOwnedTxt.Text = result;
Could anyone point me in the right direction?