Page 1 of 1

MSDAC FindKey does not work?

Posted: Wed 10 Oct 2007 08:03
by NetSupport
Hey!

I have problems using FINDKEY, using MSDAC, latest version

Appearantly, the FindKey does NOT find the record. I have been
using findkey on BDE databases before, with no problem. Is there
anything special regarding FindKey using MSDAC?
I tried IndexFieldNames. Indexname seems to be missing?
I am searching on a integer column.

regards,

Ruud

Posted: Thu 11 Oct 2007 11:59
by Antaeus
FindKey locates records by fields that are in the primary key. If you have a table defined like the one below:

Code: Select all

CREATE TABLE [dbo].[emp11](
	[EMPNO] [int] IDENTITY(1,1) NOT NULL,
	[ENAME] [varchar](10) NULL DEFAULT (NULL),
  ...
PRIMARY KEY CLUSTERED
(
	[EMPNO] ASC
)
)
Call to FindKey([10]) will make a record current if the value of its EMPNO field equals to 10.

Posted: Thu 11 Oct 2007 12:01
by Antaeus
Use the Locate method for searching records by any field.

Posted: Tue 19 Jul 2011 14:48
by lcoelho
How do you use Locate to find a value in any field of the dataset? I thought you need to enter the fields in which to look into as one of the parameters of Locate.

Posted: Thu 21 Jul 2011 11:36
by AndreyZ
Antaeus meant that you can choose the fields by which the application will search records with the help of the Locate method, but you cannot obtain such behaviour using the FindKey method.

Posted: Fri 22 Jul 2011 06:37
by lcoelho
Okay, I understand. Thank you very much for your reply