Select to view content in your preferred language

Search (VB.NET)

1388
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
DonnaBest
Deactivated User
Hi Brian -

Sorry not to respond sooner - I was gonna test a little but haven't gotten there.  I'll tell you about the next item I'm struggling with in a sec (smile).

A few random thoughts on your issue - I may be missing what you're saying -

1)  So is the File number a text field?  I used the UCase in a variable to set the case for the textbox input string, then referenced the variable in the search criteria.  - we may be doing this a little differently.  I'm using Table.OpenShapefile("path") which may be causing me more troubles. 
2)  If you have to convert (CAST is convert yes?),  can you use the same method - converting in a string to a variable? 
3)  If the file number is numeric, would >+ or <= in the search string help?

My current headache:   I need to sort on multiple columns in my datagridview.  I'd like the datagridview to only have a few fields from the table and try to sort them that way, but I can't seem to get there from here.

Not sure I'm any help, but misery loves company, yes?

Happy Monday
Donna
0 Kudos
BrianLeroux
Frequent Contributor
Donna,
The file number is text as it may contain letters. We just call it a number internally as it has always been called that. I am using a variable in the search and can do a UCase there no problem. My issue is that i need to convert the data i am searching through to UCase also and can not find a way to do that. The reason i need to convert is because this tool I am devoloping will not just search my file numbers but any field from any feature I have selected and that may include different cases for text fields.

looking at datagridview.fill I do not see any way to specify the columns. I would actually like to do this as well and was planning on looking into it further. I will let you know what i find.
0 Kudos
DonnaBest
Deactivated User
Brian -

I've found that in order to sort multiple columns I have to use IComparer and found a function.  But it only works with String fields, so I have to figure out how to Cast or convert the value of the two numeric fields I want to sort to strings - you've had the same problem yes?

Meanwhile, I had a hard time finding how to specify the fields with the datagridview autogenerated.  Haven't looked into setting autogenerate = False.  Will let you know what I find as well.

Thanks
Donna
0 Kudos