谁能告诉我关于数据库的定位函数Locate怎么用?(100分)

  • 主题发起人 njtuwangmeng
  • 开始时间
N

njtuwangmeng

Unregistered / Unconfirmed
GUEST, unregistred user!
谁能告诉我关于数据库的定位函数Locate怎么用?我用的时候老是出错。
谢谢回复的人,我在实际用的时候,还是会出错,显示‘undeclared identifier
loCaseInsensitive’,用过的人能告诉我是怎么回事吗?谢谢了,我已经查了很久了,也
试过好多次,总是这个错误,不知道是怎么回事。
 
在use中添加DB单元就能解决问题
 
LOCATE('F_STEP_NAME;expid', vararrayof([trim(GeneralFlow_F.edit1.text),exp_id]), [loCaseInsensitive])
 
Delphi的帮助是这样写的:

Implements a virtual method for searching a dataset for a specified record and making it the active record.

function Locate(const KeyFields: string; const KeyValues: Variant; Options: TLocateOptions): Boolean; virtual;

Description

This function

Checks whether the dataset is unidirectional, and if so, raises an EDatabaseError exception.
Returns False, indicating that a matching record was not found and the active record was not changed.

Descendant classes that are not unidirectional override this method so that it locates the record where the fields
identified by the semicolon-separated list of fields in KeyFields have the values specified by the Variant or
Variant array KeyValues. Options indicates whether the search is case insensitive and whether partial matches are
supported. Locate returns True if a record is found that matches the specified criteria and that record is now active.

总之,举例来说就是这样的:
Table1.Locate('查找的内容', 查找的字段, [])

最后中括号可以不填写内容,也可以填写如下内容
loCaseInsensitive:大小写不敏感
loPartialKey :可以是查找内容的一部分
 
table1.locate(字段名,edit1.text,[]);
注意: edit1.text 是用来定位的字符串
[] 是有两种值可以选择,就如:“宁柯”同志所说。
具体使用其实你可以参考delphi的帮助文件,那里在这问题上有详细的解释。
 
别人都说了
 
接受答案了.
 
顶部