哪位哥哥用过.recordset.find()呀,给小弟讲解一下4个参数都是什么意思呀?
最好给个例子。原型: procedure Find(const Criteria: WideString; SkipRecords: Integer;
SearchDirection: SearchDirectionEnum; Start: OleVariant); safecall;
最好给个例子。原型: procedure Find(const Criteria: WideString; SkipRecords: Integer;
SearchDirection: SearchDirectionEnum; Start: OleVariant); safecall;
同意!!!
同意!!!
呵呵
SkipRows是一个数字,表示在开始查找记录前跳过的行数。缺省为0,查询从当前行开始。
SearchDirection可以是adSearchForward,表示向前搜索记录;或者adSearchBackward,表示向后搜索记录。
Start是一个书签,指出开始查找记录的位置。
如果打开相应的记录,当前指针将位于匹配的记录上,如果没有找到记录,那么将位于下面两个位置中的一个:
· 如果是向前搜索,则位于记录集末尾位置的后面,EOF被设置为True。
· 如果是向后搜索,则位于记录集开始位置的前面,BOF被设置为True。
使用书签保存位置
如果没有找到相应的记录,记录的重新定位可以由书签轻松解决,因为可以为当前位置制作书签,如果在查找记录过程中没有找到所需的记录,那么再移回到上次保存的位置。
如果找到記錄返回true;
給分吧,老兄,肯定可以
rs: _RecordSet;
编译能通过,运行就出错
ADO supports four arguments for the Find method, but the last three arguments are optional and have default values as noted below: Criteria
This BSTR parameter specifies the criteria used for locating or seeking to a record in a Recordset object.
SkipRecords
This optional parameter specifies a Long expression that indicates the number of records to skip (whether to skip the current record) when locating a record in a Recordset object. The default value for this argument is 0 (don't skip the current record). The first time a Find method is used, this argument is usually set to 0 (the default). On subsequent calls to this method to seek other records that meet the specified condition, this argument would normally be set to 1, to skip one record forward before finding the next record that matches the search Criteria. A negative value for this parameter is not supported by the Microsoft® OLE DB Provider for AS/400 and VSAM.
SearchDirection
This optional parameter is an enumeration that specifies the direction for the search. It can be one of the following enumerated values for SearchDirectionEnum: Enumeration Value Description
adSearchForward 0 Search forward from the current record.
AdSearchBackward 1 Search backward from the current record. This option is not supported by the OLE DB Provider for AS/400 and VSAM.
This optional argument defaults to adSearchForward. Start
This optional parameter specifies the starting location for a search, which can be a book or an enumeration indicating the current, first, or last record in a Recordset object. This argument is a Variant and can be either a book or one of the following enumerated values for BookEnum: Enumeration Value Description
adBookCurrent 0 The current record.
AdBookFirst 1 The first record.
AdBookLast 2 The last record.
1、输入:
ADOTable1.Locate(),按住Ctrl单击“Locate”,从而进入TCustomADODataSet.Locate
2、在TCustomADODataSet.Locate中进入TCustomADODataSet.LocateRecord
3、在TCustomADODataSet.LocateRecord中搜索“FLookupCursor.Find”,然后你就知道怎么用了。————————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
————————————————————————————————————
ADOTable1.Recordset.Find('uname',0,0,0);
编译能通过,运行就出错
ADOTable1.Recordset.Find('uname',0,0,0);
编译能通过,运行就出错
我照你的方法试了一下,不出错了可是没有效果呀,为什么呢?
ADOTable1.Recordset.Find(GetFilterStr(ADOTable1.FieldByName('deptno'), 'ya1', false), 0,
adSearchForward, EmptyParam);
Edit1.Text := ADOTable1.FieldValues['uname'];
得到的是第一条记录
我照你的方法试了一下,不出错了可是没有效果呀,为什么呢?
ADOTable1.Recordset.Find(GetFilterStr(ADOTable1.FieldByName('deptno'), 'ya1', false), 0,
adSearchForward, EmptyParam);
Edit1.Text := ADOTable1.FieldValues['uname'];
得到的是第一条记录
begin
LckTable.Recordset.MoveFirst;
LckTable.Recordset.Find('lockid='''+s1+'''',0,1,1);
end;
Edit1.Text := ADOTable1.FieldValues['userdesc'];
如果find起作用了的话,Edit1.Text应该是“在建工程”。可是现在仍然是“应收”。aiirii大哥,可不可以把这个帖子置顶呀。
LookupCursor: _Recordset;
begin
LookupCursor := ADOTable1.Recordset.Clone(1);
LookupCursor.Find(GetFilterStr(ADOTable1.FieldByName('deptno'), 'ya1', false), 0, adSearchForward, EmptyParam);
if not LookupCursor.EOF then
ADOTable1.Recordset.Book := LookupCursor.Book;
ADOTable1.Resync([rmExact, rmCenter]);
Edit1.Text := ADOTable1.FieldValues['uname'];
end;————————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
————————————————————————————————————