In a registration form I need to change a Session variable depending on how many records have been entered into the database.
The variable needs to be one value if the number is 60 or less,
another value if the number of records is between 61 and 120,
another if between 121 and 180 and something else if 181 or more.
In another registration form I've used the technique below to change the value if the number of records exceeds a certain value, but this only works with one criteria. I don't know how to formulate the "CASE WHEN" that this probably requires. Some assistance with this would be greatly appreciated. :-)
Protected Sub CountApplications()
Dim DBConn As New SqlConnection(ConfigurationManager.ConnectionStrings("JobfairsConnectionString1").ConnectionString)
Dim DBCmd As New SqlCommand
DBCmd = New SqlCommand("IF (SELECT COUNT(ApplicantID) FROM Applicants ) > 60 SELECT -1 as error FROM Applicants", DBConn) ' ELSE BEGIN INSERT INTO Applicants (householdIncomeID) VALUES (@ddlHouseholdIncome); Select SCOPE_IDENTITY() End", DBConn)
Dim priKey As Integer = DBCmd.ExecuteScalar()
If priKey < 0 Then
Session("EventTime") = "10/6/2010 12:45:00 AM"
Session("EventTime") = "10/6/2010 9:45:00 AM"
Catch exp As Exception
'Close Database connection
DBConn = Nothing