现在在combobox3中输入一个学生的学号码,要在原来学生表中进行查找验证是否存在,用下列语句:
if not locate('sno',vararrayof([combobox3.Text],[lopartialkey]) then
      begin
        showmessage('不存在此学生!');
        exit;
      end;
可是编译的时候不能通过,错误的信息是:
[Error] dataupdateUnit1.pas(79): Undeclared identifier: 'lopartialkey'
[Error] dataupdateUnit1.pas(79): Incompatible types: 'TLocateOption' and 'Integer'
[Fatal Error] Project1.dpr(9): Could not compile used unit 'dataupdateUnit1.pas'请指教!

解决方案 »

  1.   

    你用一个错误处理就可以搞定了
    把学生号码设为关键字段TRYEXCEPT没问题试试
      

  2.   

    if not locate('sno',combobox3.Text,[loCaseInsensitive]) then这样试试看
      

  3.   

    看看错误的提示:1 : 'lopartialkey'没声明。
                   
                   2 :类型不兼容'TLocateOption' 和 'Integer'               3 :'dataupdateUnit1.pas'这个单元不能通过编绎,就是错误发生在这个单元
    如果一、二两个错误解决了第三个也就解决了。
      

  4.   

    你的locate的参数设错了,
    第二个参数差了个括号!
    你的程序应该改为:
    if not locate('sno',vararrayof([combobox3.Text]),[lopartialkey]) then
          begin
            showmessage('不存在此学生!');
            exit;
          end;
      

  5.   

    请问还有没有别的什么方法达到这个目的呢?
    我要做的是:在中combobox中输入一个学号,然后在学生表student.db的字段 sno中查找是否存在
    如果存在,就showmessage('存在!'); 否则就showmessage('不存在!');
      

  6.   

    我一般用SQL语句来查询,不直接用表