Must declare the scalar variable @Region RRS feed

  • Question

  • i am trying to filter out the data in the grid view according to certain input by the user but before i do that i found a way to hide columns by using


    i tried using the sql statement but it failed....

    then i tried filter rows using the sql statment using this code

    Dim str As String


    str = "SELECT * FROM [Project] WHERE([Region] = @Region1)"


    SqlDataSource1.SelectCommand = ""

    SqlDataSource1.SelectCommand = str

    SqlDataSource1.SelectParameters.Add("@Region1", "Central")



    and then i got the following error

    Must declare the scalar variable @Region


    Wednesday, January 28, 2009 6:49 AM


  • What kind of database are you using is it SQL Server? I also see that in error message it is complaining about @Region, but in your SQL statement it is @Region1, so do you look into correct spot?
    Val Mazur (MVP)
    • Marked as answer by Ibrahim sh Monday, March 9, 2009 6:18 AM
    Wednesday, January 28, 2009 10:42 AM