Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Compare data in vb

Hey guys..m just tryin to compare data in visual basic with data in access but i dont know how to proceed with it. can anyone help me out...just to explain further what i m doin is:

i m creating a flight enquiry system in which a person email me..that email is then copied into the text file. that text file is opened in visual basic and all the words are broken down into seperate line for example, my name is bob and i wanna book a flight from heathrow to america. this is the email a person sends us. when this is opened in vb it appears as
my
name
is
bob
and
i
wanna
book
a
flight
from
heathrow
to
america.

the words i want to match with the database in access are Bob, heathrow and america. the data is already there in access but i dunno how to do it...can neone help me out plz.
thankyou
[886 byte] By [asma.irshad] at [2007-11-11 10:17:50]
# 1 Re: Compare data in vb
The first place to start is to open the database in access, create a query that searchs for those specific entries (Bob, heathrow, america). Once you have a query that returns the records that you would expect based on those items, then open the query in SQL mode. Copy the SQL and move it to a VB String. Remember that any quote marks in your SQL statement will have to be doubled when you assign it to the string variable. Example:
SELECT * FROM tblReservation WHERE [Airport] = "heathrow" And [Destination] = "america" And [FirstName] ="Bob";
...becomes
Dim strSQL As String
strSQL = "SELECT * FROM tblReservation WHERE [Airport] = ""heathrow"" And [Destination] = ""america"" And [FirstName] =""Bob"";"

Now change the SQL to replace the items you entered from access (Bob, heathrow, america) into variables from your program Like this:
strSQL = "SELECT * FROM tblReservation WHERE [Airport] = """ & strAriport & """ And [Destination] = """ & strDestination & """ And [FirstName] =""" & strFirstName & """;"

Now when you read your file you can set the variables to the values you just read in and use the assignment statement above to create the needed SQL statement. Now all you have to do is open a connection to your database and open a recordset object using the SQL statement that you created above.
Ron Weller at 2007-11-11 17:22:45 >
# 2 Re: Compare data in vb
bt the ting is everythin is done automatically. i kinda need a loop wich keeps findin the match until it finds one, n if it doesnt then it tells no match found, got it?
asma.irshad at 2007-11-11 17:23:53 >