I am not sure why I am getting this error. The description of my problem is below the code. I have excluded some of the Select Cases and fields in the below code to keep it as short as possible.
Private Sub SetClassGrid(ByVal ClassCategory As String)
Dim connectionString As String = WebConfigurationManager.ConnectionStrings("theDataBase").ConnectionString
Dim con As New SqlConnection(connectionString)
Dim sqlCommand As StringBuilder = New StringBuilder()
sqlCommand.Append("SELECT Name, City, State FROM Classes$ WHERE (ClassesCategoryID = ")
Select Case ClassCategory
Case "Art"
sqlCommand.Append("1)")
Case "Drama"
sqlCommand.Append("2)")
Case "Aquarium"
sqlCommand.Append("2)")
End Select
Dim cmd As String = sqlCommand.ToString()
Dim da As New SqlDataAdapter(cmd, con)
Dim ds As New DataSet()
Try
con.Open()
da.Fill(ds, "Classes$")
Finally
con.Close()
End Try
GridView1.DataSource = ds.Tables("Classes$")
GridView1.DataBind()
End Sub
For the Select Case- when ClassCategory = "Art" it works fine; however when ClassCategory equals anything else, I get an error.
Also for the Select Case- if the case is "Art" and if I change sqlCommand from ="1)" to ="2)" it works as intended.
So the issues are that the above code only works for the first Case.

sqlCommandwhen the error occurs?