|
-
Aug 10th, 2006, 07:33 PM
#1
Thread Starter
Lively Member
[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 atabase 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
-
Aug 10th, 2006, 07:39 PM
#2
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 & "*'"
-
Aug 10th, 2006, 07:41 PM
#3
Addicted Member
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 & "%'"
Last edited by o0yuna0o; Aug 10th, 2006 at 07:45 PM.
-
Aug 10th, 2006, 07:41 PM
#4
Thread Starter
Lively Member
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?
-
Aug 10th, 2006, 07:42 PM
#5
Thread Starter
Lively Member
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...
-
Aug 10th, 2006, 07:50 PM
#6
Addicted Member
Re: PLEASE HELP.. I have problem on using the LIKE on SELECT... in vb program 6.0
 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,"*", "%")
-
Aug 10th, 2006, 07:55 PM
#7
Addicted Member
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,"*","%") & "'"
-
Aug 10th, 2006, 07:57 PM
#8
Thread Starter
Lively Member
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..
-
Aug 10th, 2006, 08:03 PM
#9
Addicted Member
Re: PLEASE HELP.. I have problem on using the LIKE on SELECT... in vb program 6.0
 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..
no problem...
Mark this thread resolved if your problem is answered
-
Aug 10th, 2006, 08:06 PM
#10
Re: [RESOLVED] PLEASE HELP.. I have problem on using the LIKE on SELECT... in vb program 6.0
Glad we could help
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|