ASP.net, c#, sql command Must Declare the Scalar Variable for User Control : I have a sql command. I tested it selecting top 5 to make sure it was connected and mapped to the write datasoure. I can select the top 5. But, when I try to select with the HostID I ge the error "Must Declare the Scalar Variable". The command executes when the page loads and also when the user changes the value in the dropdownlist.

Visual Studio 2017 Community, Asp.net 4.6, Ado, c#, Microsoft SQL Server 2016


protected void Page_LoadComplete(object sender, EventArgs e)
{
 
    //MessageBox.Show("You are in the Form.Shown event.");

    {
        SqlConnection con = new SqlConnection(Database.ConnectionString);
        try
        {
            con.Open();
            //SqlCommand cmd = new SqlCommand("select * from courses", con);

            /***** code for current or next session for instructor  *****/
            //Declare @Now2 datetime = current_timestamp,
            //         @HostID2 varchar(15) = '104402'; /*--this would be hostID of the instructor logged into attendance page*/


            SqlCommand cmd = new SqlCommand("select distinct" +
                " sd.scheduledaysid as RecordID" +
                ",sd.status" +
                ",sd.minutes" +
                ",sm.crs_cde as CourseCode" +
                ",sm.crs_title as CourseTitle" +
                ",sm.yr_cde,sm.trm_cde" +
                ",sd.startTime as StartTime" +
                ",sd.startTime" +
                ",flt.instrctr_id_num as InstructorID" +
                ",n.First_Name" +
                ",n.Last_Name as InstructorName" +
                " from ics_net.dbo.LMS_ScheduleDays as sd" +
                " inner join ics_net.dbo.lms_section as s" +
                " on sd.sectionid = s.SectionID " +
                "inner JOIN ics_net.dbo.LMS_Course AS c " +
                "WITH (NOLOCK) ON s.CourseID = c.CourseID " +
                "inner join tmseprd.dbo.section_master as sm" +
                " on c.CourseCode + ' ' + s.NAME = sm.crs_cde " +
                "and left(s.erpcoursekey,4) = sm.yr_cde " +
                "and substring(s.ERPCourseKey,6,2) = sm.trm_cde " +
                "inner join tmseprd.dbo.student_crs_hist as sch " +
                "on sm.crs_cde = sch.crs_cde " +
                "and sm.yr_cde = sch.yr_cde " +
                "and sm.trm_cde = sch.trm_cde " +
                "inner join tmseprd.dbo.faculty_load_table " +
                "as flt on sm.crs_cde = flt.crs_cde " +
                "and sm.yr_cde = flt.yr_cde " +
                "and sm.trm_cde = flt.trm_cde " +
                "inner join TmsePrd.dbo.NAME_MASTER " +
                "as n on n.id_num = flt.instrctr_id_num " +
                "where  sd.startdate <= @Now and sd.enddate >= @Now " +
                "and flt.INSTRCTR_ID_NUM = @@HostID and sm.crs_cde not like 'ONSO%' " +
                "or sd.startdate <= dateadd(mi,30,@Now) " +
                "and sd.enddate >= dateadd(mi,30,@Now) " +
                "and flt.INSTRCTR_ID_NUM = @@HostID " +
                "and sm.crs_cde not like 'ONSO%'", con);

            cmd.Parameters.AddWithValue("@RecordID", txtRecordID.Text);
            cmd.Parameters.AddWithValue("@@HostID", "Int");
            SqlDataReader dr = cmd.ExecuteReader();
            if (dr.Read())
            {
                // display data in textboxes
                txtRecordID.Text = dr["RecordID"].ToString();
                txtInstructorID.Text = dr["InstructorID"].ToString();
                txtInstructorName.Text = dr["InstructorName"].ToString();
                txtCourseCode.Text = dr["CourseCode"].ToString();
                txtCourseTitle.Text = dr["CourseTitle"].ToString();
                txtAttendanceCode.Text = dr["AttendanceCode"].ToString();
                btnUpdate.Enabled = true;
            }
            else
            {
                //lblMsg.Text = "Sorry! Invalid attendance Id";
                btnUpdate.Enabled = false;
            }
            dr.Close();
        }