943,708 Members | Top Members by Rank

Ad:
Oct 29th, 2008
0

using find command in two given variable

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
locsin is offline Offline
47 posts
since Aug 2007
Oct 29th, 2008
0

Re: using find command in two given variable

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 & "' "
Reputation Points: 11
Solved Threads: 49
Posting Whiz
jireh is offline Offline
316 posts
since Jul 2007
Oct 29th, 2008
0

using find command in two given variable

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
Reputation Points: 26
Solved Threads: 40
Posting Whiz
aktharshaik is offline Offline
316 posts
since Aug 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: label disappears
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: How I Creat Shortcut of My Project On Desktop





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC