By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,066 Members | 1,826 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,066 IT Pros & Developers. It's quick & easy.

Need Help for Search

P: 1
im having problem, with my searchform theres always an error,

Expand|Select|Wrap|Line Numbers
  1. If cmbcourse.Text = "" Or txtfind = "" Then
  2.         Adodc1.Recordset.Filter = ""
  3.         Adodc1.Refresh
  4.         Exit Sub
  5.     End If
  6.    Adodc1.Recordset.Filter = cmbcourse & " LIKE '*" & txtfind & "*'" this parts always bring error
  7. End Sub
Jan 20 '08 #1
Share this Question
Share on Google+
12 Replies


100+
P: 274
try this

Adodc1.Recordset.Filter = cmbcourse & " LIKE '" & txtfind & "%'"

instead of this
Jan 20 '08 #2

daniel aristidou
100+
P: 491
try this

Adodc1.Recordset.Filter = cmbcourse & " LIKE '" & txtfind & "%'"

instead of this
I experienced similar problems and kinda gave up......
What does % do?
Jan 20 '08 #3

lotus18
100+
P: 866
try this
Expand|Select|Wrap|Line Numbers
  1.   Adodc1.Recordset.Filter = cmbcourse & " LIKE '" & txtfind  & "%'"
  2.  
instead of this

Hi Daniel

% is a wildcard character in string comparison (sql). You can also try this code

Expand|Select|Wrap|Line Numbers
  1.   Adodc1.Recordset.Filter = cmbcourse & " LIKE '%" & txtfind  & "%'"
  2.  

Rey Sean
Jan 21 '08 #4

daniel aristidou
100+
P: 491
Hi Daniel

% is a wildcard character in string comparison (sql). You can also try this code

Expand|Select|Wrap|Line Numbers
  1.   Adodc1.Recordset.Filter = cmbcourse & " LIKE '%" & txtfind  & "%'"
  2.  

Rey Sean
My problem is that im searching the primary key. which is in the format of int32... i convert my string in the seach textbox but still get an error message invalid comparison (or something like that) System.string & system.int32
Jan 21 '08 #5

Expert 5K+
P: 8,434
So, either cmbcourse or txtfind is returning an integer, from the sound of it.
Jan 21 '08 #6

daniel aristidou
100+
P: 491
So, either cmbcourse or txtfind is returning an integer, from the sound of it.
Thats what i dont get...... the dat column is in the form of int32 and
im converting my textbox string in to int32 and im still getting the same result
Jan 21 '08 #7

debasisdas
Expert 5K+
P: 8,127
If searching on the primary key field why to use LIKE search .
Jan 21 '08 #8

daniel aristidou
100+
P: 491
Well i was using like because of column searched changes with the change of selection of a combo box.......il try using = i supose...but i means putting in a case.........or if
Jan 21 '08 #9

debasisdas
Expert 5K+
P: 8,127
My problem is that im searching the primary key. which is in the format of int32...
since searching on PK of int type .there is no use of LIKE at all.
Jan 21 '08 #10

Expert 5K+
P: 8,434
I think we need more detail here on cmbcourse, txtfind, the database fields being identified in cmbcourse, and basically, what the heck you are trying to put into Filter, which is a string.
Jan 21 '08 #11

daniel aristidou
100+
P: 491
Fixed it ............thanks for the tips
Jan 23 '08 #12

Expert 5K+
P: 8,434
Fixed it ............thanks for the tips
Cool. Glad you got it sorted.
Jan 24 '08 #13

Post your reply

Sign in to post your reply or Sign up for a free account.