![]() |
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
This function may used to check if two names match because they are in the same
nickname group. Only the first word of each string will be used.
The ProcessingFirstName property is ignored and assumed to be 'True'. No
phonetic matching will occur.
|
||||||||||||||||||||||||||||||||||||
|
Extract the zip file and place the SoundsLike.DLL in the desired location. |
|
Open a .Net Command Prompt window. Usually found under Windows at: "Start" > "All Programs" > "Microsoft Visual Studio .NET 2003" > "Visual Studio .NET Tools" > "Visual Studio .NET 2003 Command Prompt" |
|
Change directory to where the SoundsLike.DLL is located. |
|
Run this command from the Command Prompt: tlbexp SoundsLike.dll /out:SoundsLike.tlb
|
|
Run this command from the Command Prompt: regasm /tlb=SoundsLike.tlb SoundsLike.dll
|
|
Run this command from the Command Prompt: gacutil /if SoundsLike.dll
|
|
Open your VB6 project. |
|
Open the References window by selecting "Project" > "References..." from the tool bar. |
|
Select "SoundsLike Phonetic Tokenizer" and click "OK". |
Private Sub btnIntialLoad_Click() '--------------------------------------------------------------------------- 'Create an instance of the SoundsLike Phonetic Tokenizer '--------------------------------------------------------------------------- Dim objToken As SoundsLike.TokenMaker Set objToken = New SoundsLike.TokenMaker objToken.LicenseKey = "*--- license key here ---*" objToken.PreScrubbingEnabled = True Dim slTokenFirstName As Long Dim slTokenLastName As Long Dim slNicknameGroup As Long '--------------------------------------------------------------------------- 'Define and establish database connection '--------------------------------------------------------------------------- Dim objConn As ADODB.Connection Dim objConnUpd As ADODB.Connection Dim objRs As ADODB.Recordset Dim strSQL As String Set objConn = CreateObject("ADODB.Connection") Set objConnUpd = CreateObject("ADODB.Connection") Set objRs = CreateObject("ADODB.Recordset") objConn.ConnectionString= _ "Driver={SQLServer};Server=SNDLK;Database=dbCustomer;UID=xxx;PWD=xxx;" objConn.CommandTimeout = 90 ' seconds objConn.ConnectionTimeout = 45 ' seconds objConn.Open objRs.ActiveConnection = objConn objConnUpd.ConnectionString = objConn.ConnectionString objConnUpd.Open '--------------------------------------------------------------------------- 'Build SQL '--------------------------------------------------------------------------- objSQL = "SELECT CustomerID, FirstName, LastName " _ & "FROM dbo.tblTestPerson " _ & "WHERE (TokenFirstName < 1) OR (TokenLastName < 1)" '--------------------------------------------------------------------------- 'Execute SQL '--------------------------------------------------------------------------- Set objRs = CreateObject("ADODB.Recordset") objRs.ActiveConnection = objConn objRs.Open objSQL '--------------------------------------------------------------------------- 'Loop thru and tokenize all existing names already in the database ' ===This is a one-time operation to pre-tokenize existing data=== '--------------------------------------------------------------------------- While Not objRs.EOF 'Tokenize the first name and get the nickname group (if any) objToken.ProcessingFirstName = True objToken.StringToTokenize = objRs("FirstName") slTokenFirstName = objToken.TokenNarrow slNicknameGroup = objToken.DiminutiveGroup If slNicknameGroup = -1 Then slNicknameGroup = 0 'Use 0 to indicate no nickname 'Tokenize the last name objToken.ProcessingFirstName = False objToken.StringToTokenize = objRs("LastName") slTokenLastName = objToken.TokenNarrow strSQL = "Update tblTestPerson " _ & "Set TokenFirstName = " & slTokenFirstName & "," _ & " TokenNickNameGrp = " & slNicknameGroup & "," _ & " TokenLastName = " & slTokenLastName & " " _ & "Where CustomerID = " & objRs("CustomerID") objConnUpd.Execute strSQL objRs.MoveNext Wend '--------------------------------------------------------------------------- 'Clean up '--------------------------------------------------------------------------- objRs.Close objConn.Close objConnUpd.Close Set objRs = Nothing Set objConn = Nothing Set objConnUpd = Nothing Set objToken = Nothing End Sub
Private Sub btnSearch_Click() '--------------------------------------------------------------------------- 'Create an instance of the SoundsLike Phonetic Tokenizer '--------------------------------------------------------------------------- Dim objToken As SoundsLike.TokenMaker Set objToken = New SoundsLike.TokenMaker objToken.LicenseKey = "*--- license key here ---*" objToken.PreScrubbingEnabled = True objToken.ProcessingFirstName = True Dim slTokenFirstName As Long Dim slTokenLastName As Long Dim slNicknameGroup As Long '--------------------------------------------------------------------------- 'Tokenize the first name the user is looking for ' and get the nickname group (if any) '--------------------------------------------------------------------------- objToken.StringToTokenize = tbFirstName.Text If Not objToken.IsValid Then MsgBox (objToken.ErrorMessage) 'Testing slTokenFirstName = objToken.TokenNarrow slNicknameGroup = objToken.DiminutiveGroup '--------------------------------------------------------------------------- 'Tokenize the last name the user is looking for '--------------------------------------------------------------------------- objToken.ProcessingFirstName = False If Not objToken.IsValid Then MsgBox (objToken.ErrorMessage) 'Testing objToken.StringToTokenize = tbLastName.Text slTokenLastName = objToken.TokenNarrow '--------------------------------------------------------------------------- 'Define and establish database connection '--------------------------------------------------------------------------- Dim objConn As ADODB.Connection Dim objRs As ADODB.Recordset Dim strSQL As String Set objConn = CreateObject("ADODB.Connection") Set objRs = CreateObject("ADODB.Recordset") objConn.ConnectionString = _ "Driver={SQL Server};Server=SNDLK;Database=dbCustomer;UID=xxx;PWD=xxx;" objConn.CommandTimeout = 90 ' seconds objConn.ConnectionTimeout = 45 ' seconds objConn.Open objRs.ActiveConnection = objConn '--------------------------------------------------------------------------- 'Build SQL - THIS IS HOW IT'S DONE RIGHT HERE > > > ' look for text matches AND numeric token matches '--------------------------------------------------------------------------- objSQL = "SELECT FirstName, MiddleName, LastName, " _ & "PhotoURL, PhotoOnFile, PhotoShownOutside, SpouseName " _ & "FROM dbo.tblTestPerson " _ & "WHERE ( (FirstName = '" & Trim(tbFirstName.Text) & "') " _ & "OR (TokenFirstName = " & slTokenFirstName & ") " _ & "OR (TokenNickNameGrp = " & slNicknameGroup & ") ) " _ & "AND ( (LastName = '" & Trim(tbLastName.Text) & "') " _ & "OR (TokenLastName = " & slTokenLastName & ") ) " _ & "ORDER BY LastName, FirstName" '--------------------------------------------------------------------------- 'Execute SQL '--------------------------------------------------------------------------- Set objRs = CreateObject("ADODB.Recordset") objRs.ActiveConnection = objConn objRs.Open objSQL '--------------------------------------------------------------------------- 'Process results '--------------------------------------------------------------------------- While Not objRs.EOF 'Load search result screen here objRs.MoveNext Wend '--------------------------------------------------------------------------- 'Clean up '--------------------------------------------------------------------------- objRs.Close objConn.Close Set objRs = Nothing Set objConn = Nothing Set objToken = Nothing End Sub

| © 2005-09 Pamphylia.net, Inc. | Home | About | Benefits | Online Demos | Download | Purchase | Support |