c# asp.net problem with 'must declare the scalar variable'

Posted by Verian on Stack Overflow See other posts from Stack Overflow or by Verian
Published on 2010-03-19T11:54:17Z Indexed on 2010/03/19 12:01 UTC
Read the original article Hit count: 121

Filed under:
|

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?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about c#