Select to view content in your preferred language

Search (VB.NET)

1387
12
03-30-2011 08:05 AM
BrianLeroux
Frequent Contributor
I am having an issue searching using VB.NET. I am using the following to search a file number but it needs to be entered exactly as in the table.

Dim SrchStr As String = "File_Numbe = " & SrchTxt

I want to be able to enter a patial number and give me the matching results. I have tried the following with no success. Any ideas?

Dim SrchStr As String = "File_Numbe LIKE % " & SrchTxt & "%"
Dim SrchStr As String = "File_Numbe LIKE '% " & SrchTxt & "%'"
0 Kudos
12 Replies
MargoBlosser
Deactivated User
This has worked for me:
Dim whereClause As String = ("Situsall LIKE" + Space(1) + "'" + Tboxsearch.Text + "%" + "'")

Best Regards,

Margo
0 Kudos
BrianLeroux
Frequent Contributor
Thanks Margo. Unfortunately it did not work.
0 Kudos
DonnaBest
Deactivated User
Hi Brian -

Did you find a way to do this?  I have a similar situation and thought Type Ahead functionality might do the trick..  so I'm investigating how to do that?

I know your post was a while ago, thanks for your time

Donna
0 Kudos
BrianLeroux
Frequent Contributor
Donna- Actually this thread started yesterday. I think you were looking at my "joined date". Anyhow, I have still not found a solution and am still investigating.
0 Kudos
DonnaBest
Deactivated User
Brian - 

Hope this helps..it worked for me.  Not much different from Margo's so I'm curious to see if it works for you as well..

             Dim StreetString As String = UCase(StreetSearch.Text)
             Dim BuildTable As Table = Table.OpenShapefile("C:\Maps\ArcGISExplorer\Intersections.shp")
            searchFilter.WhereClause = "STREET like'" + StreetString + "%'"

(I Was at your 'join' date - but I see where to find the post date now - thanks!)

Donna
0 Kudos
BrianLeroux
Frequent Contributor
Donna-

That did not work for me. It allows me to search for an exact match put does not work for a partila match. ie- I can search for 1234 and find the file but if i try 12 it does not find 1234.

Thanks.
Brian
0 Kudos
BrianLeroux
Frequent Contributor
Donna -

Good news. It did actually work. I had the old add-in stuck in cache and my updated code didn't go through.  Thanks for your help..

searchCriteria.WhereClause = "File_Numbe LIKE'%" & SrchTxt & "%'"

Try
    Dim rows As RowCollection = layer.Table.Search(searchCriteria)
0 Kudos
DonnaBest
Deactivated User
Oh that's great!   Reminds me to go read up a little on cache - so win-win!

Donna
0 Kudos
BrianLeroux
Frequent Contributor
So my next problems with my Search Add-in..
1) The search is case sensitive and I would like it not to be. I was going to use UCase on the search string and the column data. However, since I am using table.search there is no select statement to use UCase on the column I am searching.

2) I would like to use LIKE in the where clause for my columns formatted as numbers. That would mean i need to CAST them as a string. As in the case of the issue abouve, since there is no select statement I can't perform a CAST on the field I am searching.

Any ideas are appreciated.
0 Kudos