Created
September 10, 2012 18:46
-
-
Save ryankinal/3692856 to your computer and use it in GitHub Desktop.
current vs. ideal search results
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' This is the ideal situation, where getting search results is abstracted | |
' The stored-proc code is instead moved to the Market class, and thus written only once | |
' no matter how many pages want this data | |
Dim searchMarket as New Market(licenseType, state) ' maybe with more arguments | |
Me.datalistCourses.DataSource = searchMarket.OnlineCourses() ' maybe with more arguments | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' This is the current situation. It's nowhere near DRY | |
' On every page that needs search results. This may include: | |
' -- generic query-string based search pages | |
' -- market-specific landing pages | |
' -- license-specific landing pages | |
Dim dsResults As New DataSet | |
Dim GA As New GenericDA.GenericDataAccess | |
Dim params(5) As SqlClient.SqlParameter | |
params(0) = New SqlClient.SqlParameter | |
params(0).ParameterName = "@OtherLicTypes" | |
params(0).Direction = ParameterDirection.Input | |
params(0).Value = Licenses | |
params(0).SqlDbType = SqlDbType.VarChar | |
params(1) = New SqlClient.SqlParameter | |
params(1).ParameterName = "@OtherStates" | |
params(1).Direction = ParameterDirection.Input | |
params(1).Value = States | |
params(1).SqlDbType = SqlDbType.VarChar | |
params(2) = New SqlClient.SqlParameter | |
params(2).ParameterName = "@PartnershipID" | |
params(2).Direction = ParameterDirection.Input | |
params(2).Value = 0 | |
params(2).SqlDbType = SqlDbType.Int | |
params(3) = New SqlClient.SqlParameter | |
params(3).ParameterName = "@AgencyCodeID" | |
params(3).Direction = ParameterDirection.Input | |
params(3).Value = Agency | |
params(3).SqlDbType = SqlDbType.VarChar | |
params(4) = New SqlClient.SqlParameter | |
params(4).ParameterName = "@ShoppingCartID" | |
params(4).Direction = ParameterDirection.Input | |
params(4).Value = CartID | |
params(4).SqlDbType = SqlDbType.Int | |
params(5) = New SqlClient.SqlParameter | |
params(5).ParameterName = "@StudentID" | |
params(5).Direction = ParameterDirection.Input | |
params(5).Value = StudentID | |
params(5).SqlDbType = SqlDbType.Int | |
GA.CallStoreProcedure("spNormalSearchCourses", params, CONN, dsResults) | |
Me.datalistCourses.DataSource = dsResults.Tables(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment