FAQ

GoHook’s Google-Like Search

www.GoHook.com

 

What does it do?

Now you can have the power and flexibility of a Google-like input for your database.  GoHook converts user input (including quotation marks, logical AND, OR and NOT) and converts to a valid SQL SELECT statement. 

 

 

User Input box example 1

Hello world

Converts to

SELECT * FROM Customers WHERE  ' '+Field+' ' LIKE '% Hello %' AND ' '+Field+' ' LIKE '% world %'

 

 

User Input box example 2

this –that

Converts to

SELECT * FROM Customers WHERE  ' '+Field+' ' LIKE '% this %' AND NOT ' '+Field+' ' LIKE '% that %'

 

 

User Input box example 3

(this that) OR "the other thing"

Converts to

SELECT * FROM Customers WHERE (' '+Field+' ' LIKE '% this %' AND ' '+Field+' ' LIKE '% that %') OR ' '+Field+' ' LIKE '% the other thing %'

 

Below are many more examples showing the power and flexibility of the user input.

 

 

Quickstart for Visual Studios

Though there are many optional parameters, here are the necessary steps to add GoHook’s search to your Visual Studio project:

 

 

·         Add the reference  GoHookMain.dll to your VS project

·         Instantiate the GoHook object, for example,
     
Dim myGoHook = New GoHook.GoHook.GoHookClass

·         Set a SQL Command prefix, ending with WHERE, something like this:
    
myGoHook.CommandPrefix = "SELECT * FROM Customers WHERE”

·         Set the fields you want to search (at least one), for example,
    
myGoHook.SQLFieldName = "CompanyName

·         Call GoHook to return a valid SQL query statement from user input,
   
sSQLClause = myGoHook.SQLClause(tbUserInput.Text.ToString)

 

The string sSQLClause returns the SELECT statement you can use to query your database.

 


 

 

Examples – Various user inputs—including some complex and weird ones—and what’s returned.

User Input

GoHook’s return string

 

Hello world

SELECT * FROM Customers WHERE  ' '+CompanyName+' ' LIKE '% Hello %' AND ' '+CompanyName+' ' LIKE '% world %'

 

“Hello world”

SELECT * FROM Customers WHERE  ' '+CompanyName+' ' LIKE '% hello world %'

 

This OR that

SELECT * FROM Customers WHERE  ' '+CompanyName+' ' LIKE '% This %' OR ' '+CompanyName+' ' LIKE '% that %'

 

This that

SELECT * FROM Customers WHERE  ' '+CompanyName+' ' LIKE '% This %' AND ' '+CompanyName+' ' LIKE '% that %

 

This AND that

SELECT * FROM Customers WHERE  ' '+CompanyName+' ' LIKE '% This %' AND ' '+CompanyName+' ' LIKE '% that %'

 

this and that

SELECT * FROM Customers WHERE  ' '+CompanyName+' ' LIKE '% this %' AND ' '+CompanyName+' ' LIKE '% and %' AND ' '+CompanyName+' ' LIKE '% that %'

 

this or that

SELECT * FROM Customers WHERE  ' '+CompanyName+' ' LIKE '% this %' AND ' '+CompanyName+' ' LIKE '% or %' AND ' '+CompanyName+' ' LIKE '% that %'

this -that

SELECT * FROM Customers WHERE  ' '+CompanyName+' ' LIKE '% this %' AND NOT ' '+CompanyName+' ' LIKE '% that %'

 

this NOT that

SELECT * FROM Customers WHERE  ' '+CompanyName+' ' LIKE '% this %' AND NOT ' '+CompanyName+' ' LIKE '% that %'

 

this not that

SELECT * FROM Customers WHERE  ' '+CompanyName+' ' LIKE '% this %' AND ' '+CompanyName+' ' LIKE '% not %' AND ' '+CompanyName+' ' LIKE '% that %'

(this that) OR "the other thing"

SELECT * FROM Customers WHERE  (' '+CompanyName+' ' LIKE '% this %' AND ' '+CompanyName+' ' LIKE '% that %') OR ' '+CompanyName+' ' LIKE '% the other thing %'

 

(recover from malformed " search input string ( #^&%^

SELECT * FROM Customers WHERE  ' '+CompanyName+' ' LIKE '% recover %' AND ' '+CompanyName+' ' LIKE '% from %' AND ' '+CompanyName+' ' LIKE '% malformed %' AND ' '+CompanyName+' ' LIKE '% search %' AND ' '+CompanyName+' ' LIKE '% input %' AND ' '+CompanyName+' ' LIKE '% string %' AND ' '+CompanyName+' ' LIKE '% #^&^ %'

1..5

SELECT * FROM Customers WHERE  (' '+CompanyName+' ' LIKE '% 1 %' OR ' '+CompanyName+' ' LIKE '% 2 %' OR ' '+CompanyName+' ' LIKE '% 3 %' OR ' '+CompanyName+' ' LIKE '% 4 %' OR ' '+CompanyName+' ' LIKE '% 5 %')

 

he*

SELECT * FROM Customers WHERE  (' '+CompanyName+' ' LIKE '% he %' OR ' '+CompanyName+' ' LIKE '% he_ %' OR ' '+CompanyName+' ' LIKE '% he__ %' OR ' '+CompanyName+' ' LIKE '% he___ %' OR ' '+CompanyName+' ' LIKE '% he____ %' OR ' '+CompanyName+' ' LIKE '% he_____ %' OR ' '+CompanyName+' ' LIKE '% he______ %')

 

*xyz

SELECT * FROM Customers WHERE  (' '+CompanyName+' ' LIKE '% xyz %' OR ' '+CompanyName+' ' LIKE '% _xyz %' OR ' '+CompanyName+' ' LIKE '% __xyz %' OR ' '+CompanyName+' ' LIKE '% ___xyz %' OR ' '+CompanyName+' ' LIKE '% ____xyz %' OR ' '+CompanyName+' ' LIKE '% _____xyz %' OR ' '+CompanyName+' ' LIKE '% ______xyz %')

)()()()silly""""""))(((()))))

SELECT * FROM Customers WHERE  ' '+CompanyName+' ' LIKE '% silly %'

-everything

SELECT * FROM Customers WHERE  ' '+CompanyName+' ' LIKE '% not %' AND ' '+CompanyName+' ' LIKE '% everything %'

weird chars % “ ‘ =

SELECT * FROM Customers WHERE  ' '+CompanyName+' ' LIKE '% weird %' AND ' '+CompanyName+' ' LIKE '% chars %' AND ' '+CompanyName+' ' LIKE '% = %'

drop table

SELECT * FROM Customers WHERE  ' '+CompanyName+' ' LIKE '% drop %' AND ' '+CompanyName+' ' LIKE '% table %'

*

SELECT * FROM Customers

[Returns entire table if myGoHook.AllRowsCharacter = "*"]

 

 

 

 

Reserved Words and Punctuation

Word

Notes

Same as Google?

AND

Boolean ‘AND’ in uppercase

Yes

+ [plus sign]

Boolean ‘AND’

Yes

And

Assumes you’re searching the word ‘and’

Yes

OR

Boolean ‘OR’ in uppercase

Yes

Or

Assumes you’re searching the word ‘or’

Yes

NOT

Boolean ‘NOT’ uppercase. Single words with a NOT prefix are converted to “not” AND “theword

Yes

-      [hyphen]

Boolean ‘NOT’

Yes

“hello world”

[double quotes]

Exact phrase

Yes

()

[parens]

Group logical phrases. this OR (that AND everything)

((“this and that” AND hello) OR (“me myself” AND her)) AND yes

Yes

1..5

[two dots]

Number, two periods, number.  The same as 1 OR 2 OR 3 OR 4 OR 5

Yes

he*  (asterisk)

Return all words beginning with the letters “he”

No

 

 

 

Methods and Properties

GoHookClass [Class]

 

' =============================================================================

' Main Class in the GOHOOKMAIL.DLL for these Methods and properties

'Class GoHookClass

'

'Function SQLClause(ByVal sInputString As String) As String

'

'Property AllowableInputCharacters() As String

'Property DatabaseBrand() As Integer

'Property DefaultSearchPhrase() As String

'

'ReadOnly Property GetFoundStopWords() As ArrayList

'ReadOnly Property GetGoHookDetailsHTML As String

'ReadOnly Property HasChangedSpellingWords() As Integer

'ReadOnly Property HasFoundStopWords() As Integer

'ReadOnly Property HasInputCharacters() As Boolean

'ReadOnly Property HasInputLineHasChanged1() As Boolean

'ReadOnly Property HasInputLineHasChanged2() As Boolean

'ReadOnly Property HaveDoubleQuotesChanged() As Boolean

'ReadOnly Property HaveParensChanged() As Boolean

'ReadOnly Property ScrubbedInputLine() As String

'ReadOnly Property TokenCount() As Integer

'ReadOnly Property Version() As String

'ReadOnly Property WordCount() As Integer

'

'WriteOnly Property AddLeadingAndTrailingSpaces As Boolean

'WriteOnly Property AllRowsCharacter As String

'WriteOnly Property IgnoreCaseInLogicals As Boolean

'WriteOnly Property LogFileLevel As Integer

'WriteOnly Property LogRemoteIPAddress As String

'WriteOnly Property LogTotalDBRecords As Long

'WriteOnly Property MaximumAsteriskExpansion() As Integer

'WriteOnly Property MaximumInputWords() As Integer

'WriteOnly Property ProductKey() As String

'WriteOnly Property SQLCommandPrefix() As String

'WriteOnly Property SQLCommandSuffix() As String

'WriteOnly Property SQLDataPrefix() As String

'WriteOnly Property SQLDataSuffix() As String

'WriteOnly Property SQLFieldName() As String

'

'Sub GetSpellingFile(Optional ByVal strSpellingWordsFile As String = "", Optional ByRef iSpellingCount As Integer = 0)

'Sub GetStopWords(ByRef sStopWordArray() As String, Optional ByRef iStopWordCount As Integer = 0)

'Sub GetStopWordsFile(Optional ByVal strStopWordsFile As String = "", Optional ByRef iStopWordCount As Integer = 0)

'

'Enum DatabaseTypes As Integer

'Enum LoggingLevel As Integer

 

SQLClause [Method]

' =============================================================================

' Main GoHook Method to return a database clause based on user input string

' Send

'   User input string

' Return

'   Valid SQL WHERE clause

' =============================================================================

Public Function SQLClause(ByVal sInputString As String) As String

 

 

Version [Property]

' =============================================================================

' Get the current version number of GoHookClass

' Send

'   Nothing

' Return

'  Return a string of the current GoHook version number x.xx.xx

=============================================================================

Public ReadOnly Property Version() As String

 

 

ProductKey [Property]

' =============================================================================

' Send

'   KeyGen Serial number

' Return

'   Nothing

' Notes

'   If missing or invalid, SQLClause will return a warning

'   If temporary, 75% of the searchers return a valid result, and

'    twenty-five percent return a warning

'   If licensed, 100% of SQLClause return a valid SQL Clasue

'

' =============================================================================

Public WriteOnly Property ProductKey() As String

 

 

MaximumInputWords [Property]

' =============================================================================

' Send

'   Maximum input words (token array)

'

' Notes

'  Sets the upper limit on the maximum number of words user inputs.

'  Default is 2,048 tokens

' =============================================================================

Public WriteOnly Property MaximumInputWords() As Integer

 

 

TokenCount [Property]

' =============================================================================

' Send

'   Nothing

' Return

'   Number of tokens found in user input string

' =============================================================================

Public ReadOnly Property TokenCount() As Integer

 

 

DatabaseBrand [Property]

' =============================================================================

' Send

'   The database brand of the type the caller is using (Public Enum)

'    IndexingServices = 0 [Default]

'    MicrosoftSQLServer = 1

'    MySQL = 2

'    SQLite = 3

'    Oracle = 4

' Return

'   Gets the database type per enumerations

' Notes

'   Default is Indexing Services.  Used to escape the double-quote character, as different databases

'    escape double quoted differently.  For example, MS SQL Server uses \" (backslash quote)

'    to search for quote marks in data.

'    Also used to set

'          Spaces around words (A LIKE% to InStr() inside a field is needed for database fields,

'           but not Indexing Services

'          Some databases allow underscores for wildcard characters. (Expanding asterisks)

Public Property DatabaseBrand() As Integer

 

 

AllRowsCharacter [Property]

' =============================================================================

' Send

'   Sets the user input character to retrieve all rows in database table by

'    removing WHERE clause from CommandPrefix property. Useful for testing.

'    This is set by you, not the database.  For example, while in testing

'    mode, you may assign the $ (or asterisk or backslash) to say, "return

'    all rows of the database."  You may want to reset this in production.

' Return

'   Nothing

' =============================================================================

Public WriteOnly Property AllRowsCharacter As String

 

WordCount [Property]

' =============================================================================

' Send

'   Nothing

' Return

'  Returns number of valid search words found in user input string.  These

'    are word only.  Number of tokens (words plus logical words is normally

'    larger)

' =============================================================================

Public ReadOnly Property WordCount() As Integer

 

 

AddLeadingAndTrailingSpaces [Property]

' =============================================================================

' Send

'   True/False

' Return

'   Nothing

' Notes

'   Sets the Boolean flag to prepend and append a space on each database field, so

'    searches find whole words. Setting to FALSE is similar to InStr function and

'    returns more results.

' More notes

'  This does not apply to Indexing Services, which already searches for whole

'    words.  All other database fields normally trim leading and ending

'    spaces.

'  True (helpful for most database fields)

'    GoHook dynamically adds a beginning and ending space so your

'    searches find words at the beginning and end of the field. For

'    example, here is a field in your database

'          [red blue orange yellow]

'    Without changing your database data, GoHook will do a whole word

'    search, so it returns "red" and "yellow", the words at the beginning

'    and end of the field.

'  False (returns more results and finds substrings, not words)

'    In the same field

'          [red blue orange yellow]

'    You database query will return ALL these words, which is not what

'    you want, usually (more like InStr(), not whole words):

'          red, blue, orange, or, yell, yellow, an, ow...

‘ Bottom line

   Set to True if you are searching database fields and want whole words

   Set to False if you’re using Indexing Services or want substrings returned

' =============================================================================

Public WriteOnly Property AddLeadingAndTrailingSpaces As Boolean

 

 

IgnoreCaseInLogicals [Property]

' =============================================================================

' Send

'   True/False

' Return

'   Nothing

' Notes

'  In user input string, change and to AND, or to OR, not to NOT, which

'    breaks Google compatibility and users cannot search on Boolean words.

'    Remember that many Boolean words are excluded by the StopWord file.

' =============================================================================

Public WriteOnly Property IgnoreCaseInLogicals As Boolean

 

 

LogFileLevel [Property]

' =============================================================================

' Send

'   Logging level (Public Enum)

'    Disable = 0 [Default]

'    Minimum = 1

'    Medium = 3

'    Maximum = 5

' Return

'   Nothing

' Notes

'   Turn on Logging for user admin analysis. File name is LOGFILE.TXT located

'    in executable (current) directory

' =============================================================================

Public WriteOnly Property LogFileLevel As Integer

 

 

GetGoHookDetailsHTML [Property]

' =============================================================================

' Send

'   Nothing

' Return

'  Details from the previous user input in HTML format. Useful debugging and

'    instruction on the inner workings. We use this on our Website

' =============================================================================

Public ReadOnly Property GetGoHookDetailsHTML As String

 

 

LogRemoteIPAddress [Property]

' =============================================================================

' Send

'   Set by application, not GoHookClass. Use this syntax in

'    your application:  Request.ServerVariables("REMOTE_ADDR")

' Return

'   Nothing

' Notes

'   Not a GoHook search function, but a pass-through variable so you can

'    use GoHook's logging to include IP addresses in the log file.

' =============================================================================

Public WriteOnly Property LogRemoteIPAddress As String

 

LogTotalDBRecords [Property]

' =============================================================================

' Send

'   Set by application, not GoHookClass. Optionally set the number of records

'    for logging

' Return

'   Nothing

' Notes

'   Not a GoHook search function, but a pass-through variable so you can

'    use GoHook's logging to include how many records in your database.

' =============================================================================

Public WriteOnly Property LogTotalDBRecords As Long

 

SQLFieldName [Property]

' =============================================================================

' Send

'   Sets the database field name(s), optionally prepend and append a space on

'    each data field, as set by AddSpacesToField

' Return

'   Nothing

' Notes

'  Works with AddSpacesToField

'  Will concatenate fields in the returned SQL statement.  For example

'    Send: Field1,Field2

'    Returns ' '+Field1+' '+Field2+' '

'

' =============================================================================

Public WriteOnly Property SQLFieldName() As String

 

AllowableInputCharacters [Property]

' =============================================================================

' Send

'   String of allowable characters

' Return

'   Nothing

' Notes

' Default is

'   ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ()*-."

' =============================================================================

Public Property AllowableInputCharacters() As String

 

DefaultSearchPhrase [Property]

' =============================================================================

' Send

'   String of default search word or phrase if the user simply

'    presses the [Enter] key with a blank input.

' Return

'   Returns the string

' Notes

'   In case your user simply presses the [Enter] key on an empty input string.

'     Default is blank.  Like Google.com, leaving it blank default returns an

'     empty string

'    return from SQLClause() like Google.com

' =============================================================================

‘ Public Property DefaultSearchPhrase() As String

 

 

GetSpellingFile [Method]

' =============================================================================

' Send

'   Optional: Spellng file name [Default is SPELLING.DAT from current (executable) directory]

' Return

'   Optional: Number of spelling pairs read

' Notes

'   This is a flat ASCII file with data pairs of WRONGSPELLING, RIGHTSPELLING on each line.

'   Maximum number of lines (pairs)

' =============================================================================

Public Sub GetSpellingFile(Optional ByVal strSpellingWordsFile As String = "",

         Optional ByRef iSpellingCount As Integer = 0)

 

 

GetStopWords [Method]

' =============================================================================

' Send

'   Array() of stop words (common words).  Flat ASCII file, one word per line

' Return

'   Optional: Number of stop words read

' Notes

'   Stop words are common words, usually skipped, such as "the" "an" "of".

'   Default is no stop words.

' More notes

'   Like Google.com, GoHook automatically skips words of a single character

'    or number, thus A thru Z and 0 thru 9 are unconditionally skipped.

' =============================================================================

Public Sub GetStopWords(ByRef sStopWordArray() As String,

    Optional ByRef iStopWordCount As Integer = 0)

 

 

GetStopWordsFile [Method]

' =============================================================================

' Send

'   Optional: File name to read stop words (common words).  Flat ASCII file,

'    one word per line

'   If blank or omitted, GoHook will use standard Windows stop word file

'    normally here: C:\Windows\System32\NOISE.DAT

' Return

'   Optional: Number of stop words read from file

' Notes

'   Stop words are common words, usually skipped, such as "the" "an" "of".

'   Default is no stop words.

' More notes

'   Windows keeps a file of standard stop words C:\Windows\System32\NOISE.DAT

'   Like Google.com, GoHook automatically skips words of a single character

'    or number, thus A thru Z and 0 thru 9 are unconditionally skipped.

' =============================================================================

Public Sub GetStopWordsFile(Optional ByVal strStopWordsFile As String = "",

    Optional ByRef iStopWordCount As Integer = 0)

 

 

GetFoundStopWords [Property]

' =============================================================================

' Send

'  Nothing

' Return

'   An ArrayList of the stop words input by the user

' Notes

'   Stop words are common (skipped) words

' =============================================================================

Public ReadOnly Property GetFoundStopWords() As ArrayList

 

 

HasFoundStopWords [Property]

' =============================================================================

' Send

'  Nothing

' Return

'   Returns integer with number of stop words (words skipped) found

'    in user input string

' Notes

'   Stop words are common (skipped) words.

'   For the actual words, see GetFoundStopWords

' =============================================================================

Public ReadOnly Property HasFoundStopWords() As Integer

 

 

HasChangedSpellingWords [Property]

' =============================================================================

' Send

'  Nothing

' Return

'   Returns integer with number of spelling changes made in user

'    input string

' Notes

'   Spelling words are read using GetStopWordsFile

' =============================================================================

Public ReadOnly Property HasChangedSpellingWords() As Integer

 

 

SQLCommandPrefix [Property]

' =============================================================================

' Send

'  String GoHook should return as SQL command prefix, such as

'    SELECT * FROM myTable

' Return

'   Nothing

' Notes

'   This could also be accomplished in your application, but this keeps

'      the SQL command encapsulated and allows GoHook to return the

'      entire SQL SELECT string

' =============================================================================

Public WriteOnly Property SQLCommandPrefix() As String

 

 

SQLCommandSuffix [Property]

' =============================================================================

' Send

'  String GoHook should return as SQL command suffix, such as

'    ORDER BY myField

' Return

'   Nothing

' Notes

'   This could also be accomplished in your application, but this keeps

'      the SQL command encapsulated and allows GoHook to return the

'      entire SQL SELECT string

' =============================================================================

Public WriteOnly Property SQLCommandSuffix() As String

 

 

SQLDataPrefix [Property]

' =============================================================================

' Send

'    Set the prefix string for each field in the resulting WHERE clause.

'    The default is " LIKE '% " (space LIKE space Single-Quote Percent-Sign space).

'    This searches for whole words anywhere in the field and is covered

'    in detail in AddLeadingAndTrailingSpaces

' Return

'   Nothing

' Notes

'   See AddLeadingAndTrailingSpaces for a discussion of how to search whole

'    words in database fields.

' =============================================================================

Public WriteOnly Property SQLDataPrefix() As String

 

 

SQLDataSuffix [Property]

' =============================================================================

' Send

'    Set the prefix string for each field in the resulting WHERE clause.

'    The default is " %' " (space Percent-Sign Single-Quote space).

'    This searches for whole words anywhere in the field and is covered

'    in detail in AddLeadingAndTrailingSpaces

' Return

'   Nothing

' Notes

'   See AddLeadingAndTrailingSpaces for a discussion of how to search whole

'    words in database fields.

' =============================================================================

Public WriteOnly Property SQLDataSuffix() As String

 

 

MaximumAsteriskExpansion [Property]

' =============================================================================

' Send

'   Sets number of characters (using SQL underscore) to expand asteriks,

'   Send zero to disable [Default]

'   Twelve is maximum allowed

' Return

'   Nothing

' Notes

'   Setting to three, for example, expands *ABC to (_ABC OR __ABC OR ___ABC),

'   Setting to two, for example, expands AB* to (AB_ OR AB__)

'   Underscore wildcards are allowed in some databases, but not Indexing

'    Services

' =============================================================================

Public WriteOnly Property MaximumAsteriskExpansion() As Integer

 

 

ScrubbedInputLine [Property]

' =============================================================================

' Send

'   Nothing

' Return

'   A scrubbed user input line of how GoHook interpreted parens,

'    quotation marks, logic words, skip words, misspelled words,

'     number .. expansion, asterisk expansion, etc.

' Notes

' =============================================================================

Public ReadOnly Property ScrubbedInputLine() As String

 

 

HasInputCharacters [Property]

' =============================================================================

' Send

'   Nothing

' Return

'   Boolean True/False whether the user entered characters (True) or an

'    empty string (False).

' Notes

'   The string may be empty (and thus False) for several reasons

'    1) The user pressed [Enter] with no input

'    2) Application did not set DefaultSearchPhrase

'    3) All entered words were stop (common) words and thus removed

'    4) All words were one character long. GoHook unconditionally

'       assumes all words are a minimum of two characters.

'    5) User entered just logical words.  In this case, GoHook may

'       also attempt to convert logical words to search words.

' =============================================================================

Public ReadOnly Property HasInputCharacters() As Boolean

 

 

HasInputLineHasChanged1 [Property]

' =============================================================================

' Send

'   Nothing

' Return

'   Boolean True/False whether the user's input string changed

'    True = user input string changed

'    False = user input was not scrubbed nor edited

'   GoHook made the change and recovered (unlike HasInputLineHasChanged2)

' Notes

'   The string may change for several reasons

'    1) User entered invalid characters

'    2) User entered stop words or misspelled words

'    3) Unbalanced or illogical quotation marks or parentheses

'    4) Logical words out of place or misused

'    5) Asterisk expansion

'    6) Number expansion

'    7) Other

' =============================================================================

Public ReadOnly Property HasInputLineHasChanged1() As Boolean

 

 

HasInputLineHasChanged2 [Property]

' =============================================================================

' Send

'   Nothing

' Return

'   Boolean whether the user input string was catastrophically incorrect and

'    the parser got so confused it could not correct the input.

'    True = user input string was very badly formed

'    False = user input may have been changed, but GoHook recovered

' Notes

'   GoHook made the change and could not recover (unlike HasInputLineHasChanged1)

' =============================================================================

Public ReadOnly Property HasInputLineHasChanged2() As Boolean

 

 

HaveParensChanged [Property]

' =============================================================================

' Send

'   Nothing

' Return

'   Boolean whether the user input string had mismatched (unequal number

'   of left- and right- parentheses) or simply too many parentheses

'    True = user input parentheses were correct

'    False = user input of parentheses incorrect and changed or removed

' Notes

'   GoHook may add or subtract parentheses attempting to guess user intent

' =============================================================================

Public ReadOnly Property HaveParensChanged() As Boolean

 

 

HaveDoubleQuotesChanged [Property]

' =============================================================================

' Send

'   Nothing

' Return

'   Boolean whether the user input string had mismatched (unequal number)

'   of quotation marks (ASCII 34) or simply too many

'    True = user input quotation marks were correct (even number)

'    False = input quotation marks were incorrect and changed or removed

' Notes

'   GoHook may add or subtract quotation marks attempting to guess user intent =============================================================================

Public ReadOnly Property HaveDoubleQuotesChanged() As Boolean

 

 

 

 

 

Sample Code (VB.NET)

 

Private Sub btnSQLServer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click

 

Dim sSQLClause As String                        ' Return string from GoHook

Dim mySearchResultsDS As DataSet                ' Dataset to return query results

Dim myGoHook = New GoHook.GoHook.GoHookClass    ' Instantiate GoHook Class (remember to add the reference 'GoHookMain.dll' to this project

Dim bSearchResult As Boolean = True             ' SQL error (rare, usually a bad database or field name)

Dim sErrorResult As String = ""                 ' If error in SQL, return the error message

 

myGoHook.CommandPrefix = "SELECT * FROM Customers WHERE"    ' Break SELECT command into PREFIX, ending with 'WHERE'

myGoHook.CommandSuffix = "ORDER BY CustomerID"              ' Optional suffix, typically for sorting results

myGoHook.SQLFieldName = "CompanyName"

myGoHook.WordsLikeGoogle = cbWordSearch.Checked             ' Google searches words, which begin and end with a space.  Set this to FALSE if you want substring, ignoring whitespace around words

 

sSQLClause = myGoHook.SQLClause(tbInputLine.Text.ToString)  ' Call GoHook to convert text string and boolean to valid SQL WHERE clause

'

'If user had input, display the DataSet

'

If myGoHook.HasInputCharacters Then

    DataGridView1.ClearSelection()

    mySearchResultsDS = SearchSQL(sSQLClause, sErrorResult, bSearchResult)

    If bSearchResult = True Then

       DataGridView1.DataSource = mySearchResultsDS.Tables(0)

       tbFoundQty.Text = mySearchResultsDS.Tables(0).Rows.Count.ToString

    Else

       MsgBox(sErrorResult, MsgBoxStyle.OkOnly, "GoHookMain Warning")

    End If

Else

    MsgBox("Empty or blank input", MsgBoxStyle.OkOnly, "GoHookMain Warning")

End If

 

End Sub