ASP.NET C# Must declare the scalar variable

后端 未结 6 1771
一生所求
一生所求 2021-01-17 23:56

I am trying to populate a GridView using a method called PopulateGrid() (below) but keep getting the same server error "Must Declare the scalar variable "@QUALID&q

6条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-18 00:31

    change

    cmd.Parameters.Add(new SqlParameter("QUALID", val));
    

    to either

    cmd.Parameters.Add(new SqlParameter("@QUALID", val));
    

    or

    cmd.Parameters.Add("@QUALID", SqlDbType.WhatFitsYourDB).Value = val; 
    

    and you should be good to go. Your problem is that you are missing a '@' in the paramter name

提交回复
热议问题