[RESOLVED] PLEASE HELP.. I have problem on using the LIKE on SELECT... in vb program 6.0
I am having hard time to this, when i use the...
"select * from personalinfo where
personalinfo.lastname = " & "'" & txtlastname.Text & "'"
The above work to what i am expected... however, when i am using the....
"select * from personalinfo where
personalinfo.lastname LIKE " & "'" & txtlastname.Text & "'"
This does not work as what i want which the user can type just the first 3 letters or four or etc.... of the lastname... I am using the access database as my backend...
My input includes the asterist the textbox like "SACHEZ", i put "SANC*", but this is not recognized just want to know why and is there a bug on using LIKE word in VB 6.0?
PLEASE HELP... the code is there bellow
=============================================
Option Explicit
Dim Dbhrd As Connection
Dim RsQuery As Recordset
Private Sub Form_Load()
Set Dbhrd = New Connection
Set RsQuery = New Recordset
Dbhrd.CursorLocation = adUseServer
Dbhrd.Open "PROVIDER=microsoft.jet.oledb.4.0;" & _
"Data Source=r:\hrddatafile.mdb;" & _
"Persist Security Info=False;" & _
"Jet OLEDB:Database Password=" & vpassadmin
End Sub
Private Sub RSQueryOpen()
RsQuery.Source = "SELECT * From personalinfo " & _
"WHERE personalinfo!lastname LIKE " & _
"'" & txtlastname.Text & "'"
RsQuery.ActiveConnection = Dbhrd
RsQuery.CursorLocation = adUseClient
RsQuery.LockType = adLockPessimistic
RsQuery.CursorType = adOpenKeyset
RsQuery.Open
End Sub
'THANK YOU
Re: PLEASE HELP.. I have problem on using the LIKE on SELECT... in vb program 6.0
Try this....
VB Code:
select * from personalinfo where lastname LIKE '" & txtlastname.Text & "*'"
Re: PLEASE HELP.. I have problem on using the LIKE on SELECT... in vb program 6.0
if you want to query the first three or sequence of letters ONLY.
you should do this:
"SELECT * From personalinfo " & _
"WHERE personalinfo!lastname LIKE " & _
"'" & txtlastname.Text & "%'"
Re: PLEASE HELP.. I have problem on using the LIKE on SELECT... in vb program 6.0
can i ask somethin..? what's the difference between including on textbox input and the select * from personalinfo where lastname LIKE '" & txtlastname.Text & "*'"
Is there a difference on it?
Re: PLEASE HELP.. I have problem on using the LIKE on SELECT... in vb program 6.0
no? it is not just a three letter.. the input will depend on the users input.. that was just my example...
Re: PLEASE HELP.. I have problem on using the LIKE on SELECT... in vb program 6.0
Quote:
Originally Posted by enricoisles
can i ask somethin..? what's the difference between including on textbox input and the select * from personalinfo where lastname LIKE '" & txtlastname.Text & "*'"
Is there a difference on it?
I see... try the percent sign instead of "*". The wildcard in query is "%"
If you want you can do this code replace(text1.text,"*", "%")
:wave:
Re: PLEASE HELP.. I have problem on using the LIKE on SELECT... in vb program 6.0
VB Code:
"SELECT * From personalinfo " & _
"WHERE personalinfo!lastname LIKE " & _
"'" & replace(txtlastname.Text,"*","%") & "'"
Re: PLEASE HELP.. I have problem on using the LIKE on SELECT... in vb program 6.0
its works bro... thanks... i used the % sign instead of * asterisk... thankss... hahaha... you guys are much reliable than my books hahaha.... thanksss... hahaha..
Re: PLEASE HELP.. I have problem on using the LIKE on SELECT... in vb program 6.0
Quote:
Originally Posted by enricoisles
its works bro... thanks... i used the % sign instead of * asterisk... thankss... hahaha... you guys are much reliable than my books hahaha.... thanksss... hahaha..
:D no problem...
Mark this thread resolved if your problem is answered :wave:
Re: [RESOLVED] PLEASE HELP.. I have problem on using the LIKE on SELECT... in vb program 6.0
Glad we could help :wave: