一张 adotable表, 包含字段: 用户id、月份、性名等等我要通过 用户id 及 月份 这两个字段,把数据库指针定位到一条记录下,请问这个该怎么作?谢谢了。求命呀!!!

解决方案 »

  1.   

    adotable1.first;
    while not adotable1.eof do
    begin
           if (adotable1.fieldvalue['用户id']= mid) 
                   and (adotable1.fieldvalue['月份']=mMonth) then
                   break;
           adotable1.next;
    end;
    if not adotable1.eof then
           adotable1.next;
      

  2.   

    使用locate或者findkeyadotable.open;
    adotable.Locate('id;月份', VarArrayOf(['123', 4]), [loPartialKey]);
      

  3.   

    又学会了一招
    Locate可以将当前光标定位在符合条件的记录上,Locate的第一个参数是条件字段,第二个参数是条件
    值,第三个参数指出在查找时是否考虑大小写,是否部分匹配。Locate可以设置多个条件,如下所示:
        Table1.Locate('company:contact:phone',VarArrayOf(['Sight Diver', 'P', '408-431-1000']), [loPartialKey]);