using find command in two given variable

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Aug 2007
Posts: 47
Reputation: locsin is an unknown quantity at this point 
Solved Threads: 0
locsin locsin is offline Offline
Light Poster

using find command in two given variable

 
0
  #1
Oct 29th, 2008
I want to use find command for searching file in the database, but if I add "and" command i received error. It is possible to use and in Find command

I try to this syntax but it is error

.Open "Select *From salary'", strconek, adOpenStatic, adLockOptimistic
.Find "empno = '" + vempno + "'" and "salary_month = '"smonth"'", 0, adSearchForward
if not (.eof)
msg existing
else
accept data
endif

Anybody can help me to fix this error or anyone have idea what command to use for searching a file.. The main purpose of me is to chech the employeenumber and salaryofthemonth if existing or not..

what command I will use to seek both employee number and salaryofthemonth as joint conditional statement for searching file in the database.

thanks in advance
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 300
Reputation: jireh is an unknown quantity at this point 
Solved Threads: 43
jireh's Avatar
jireh jireh is offline Offline
Posting Whiz

Re: using find command in two given variable

 
0
  #2
Oct 29th, 2008
You're already using the query so why not maximize the usage of it?

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. " Select * From Salary Where empno = '" & vempno & "' And salary_month = '" & smonth & "' "
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 304
Reputation: aktharshaik is an unknown quantity at this point 
Solved Threads: 37
aktharshaik's Avatar
aktharshaik aktharshaik is offline Offline
Posting Whiz

using find command in two given variable

 
0
  #3
Oct 29th, 2008
you can't use find method on more than one column. ADO's Recordset.Find method works on one column, and one column only. why do you want to use Find? Although it is appropriate in some situations, using it to locate records is generally very inefficient, in terms of speed and memory. Find works by examining each record in a Recordset for the criteria you give it after you have created the Recordset and retrieved all the data from your database. Retrieving lots of unwanted records, particularly down the wire from a server, when you are really interested in only a handful, or sometimes just one row of data. This creates a lot of unnecessary overhead. Unless you have a very compelling reason for using Find, I'd recommend using an alternative approach, like filtering your Recordset or using SQL, for serious performance gains.

The Recordset.Filter method filters out records that don't match one or more criteria. You can specify multiple conditions in a filter by using 'AND' or 'OR', so using Filter would allow you to check multiple columns. For example, suppose we open a Recordset and execute the following code:

rs.Filter "Country='India' and Place='Delhi'"

The Recordsetrs would then contain only records where the Country and Place fields were India and Delhi, respectively. If no records existed that match these criteria, rs would be empty, with rs.EOF and rs.BOF both true. To remove a filter from a Recordset, set the Filter property to an empty string ("") or the constant adFilterNone.

OR Lastly use a SQL SELECT statement to ensure that the Recordset contained only records with the values you are looking for. SQL processing is done by the data provider and is generally the fastest way to retrieve a restricted set of data because the only real overhead is the opening of the Recordset, which you have to do anyway.


Regards
Shaik Akthar
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC