Download the Fortunate Library Here:
Fortunate Library 32bit - Stand-Alone Install
Fortunate Library 64bit - Stand-Alone Install
Fortunate Library Solution - Source Code
The Fortuante.Search object accepts any DataTable, a list columns which should be searched, and a search word(s). It then returns a DataView with each row of the original DataTable returned in the order of best match to the search word(s) to least match.
Here is the code I use to search the Code Repository entries:
'---Create the stored procedure
Dim SQLCommand As New Data.SqlClient.SqlCommand()
SQLCommand.CommandType = Data.CommandType.StoredProcedure
SQLCommand.CommandText = "procCodeLibraryGetAllEntries"
'---Get all results from the code library to search through
Dim CodeLibraryDataTable As DataTable = Master.DataObject.GetDataTable(SQLCommand, "CodeLibraryEntriesTable")
'---Create an array of column names to search
Dim SearchColumnNames As String() = {"CategoryName", "LanguageName", "CodeTitle", "CodeDescription"}
'---Create the search object
Dim FortunateSearchObject As New Fortunate.Search
'---"CodeTitle" in the GetSearchResults method weights a row higher if a search word is found in the column name entered
CodeGridView.DataSource = FortunateSearchObject.GetSearchResults(CodeLibraryDataTable, SearchColumnNames, Master.DataObject.EscapeString(SearchTextBox.Text.Trim()), "CodeTitle")
CodeGridView.DataBind()
|