|
-
Nov 2nd, 2000, 06:34 AM
#1
Can anyone help me with making a search function?
I'm using a Access 2000 db with vb6.
My Project is: I'm gonna make a program for a video-rental-store, with posibility to search on customers name and Movie-title. Is this any help for you? Hopeing for an answer!
-
Nov 2nd, 2000, 08:34 AM
#2
New Member
What do you want help with? Setting up the connection to the db, creating tables, writing vb-code?
-
Nov 2nd, 2000, 08:35 AM
#3
Frenzied Member
you have to use ADO and sql
Code:
'assuming your ado recordset is called RS and connection is called conn
dim SQLStatement as string
If SearchByCustomer = True then
dim CustomerName as string
CustomerName = txtcustomer.text
SQLStatement = "SELECT * FROM MyTable WHERE CustomerName = '" & CustomerName & "'"
elseif SearchByTitle then
Dim VideoTitle as string
VideoTitle = txtvideotitle.text
SQLStatement = "SELECT * FROM MyTable WHERE VideoTitle = '" & VideoTitle & "'"
end if
RS.Open SQLStatement, conn
with rs
if .eof then
msgbox "nothing found"
else
'do what ever you want with whts found
end if
.close
end with
i hope that helped
if you need more help let me know
-
Nov 2nd, 2000, 08:49 AM
#4
New Member
Use LIKE instead:
SELECT * FROM MyTable WHERE CustomerName LIKE '"%" & CustomerName & "%"'"
If you typed in "Ander" the statement will find every customer which name contains Ander, for example Andersson, Anderlecht and so on :-)
I´m not that sure how to use the '%'...
-
Nov 2nd, 2000, 08:51 AM
#5
Frenzied Member
assumption was based on he wanted to check for exact
you use % by typing it at the beganning and end of the string
like this
videotitle LIKE '%kova%'
have fun sqling
-
Nov 2nd, 2000, 11:18 AM
#6
New Member
Remember LIKE is a lot slower than '='
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
|