我用的是parodox表,没有索引和关键字。

解决方案 »

  1.   

    query1.close;
    query1.sql.clear;
    query1.sql.add('select * from table1 where 年份=2000 and 学期=''上'' and 部门=''机电''');
    query1.open;
      

  2.   

    用TQuery嘛:
    SQL := 'Select * from table1 where 年份=''2000'' and 学期=''上'' and 部门=''机电''';
    设置它的RequestLive为True
      

  3.   

    用Filter呀
    filtered=true
    filter= 年份='2000' and 学期='上' and 部门='机电'
      

  4.   


    table1.filter='年份=''2000'' and 学期=''上'' and 部门=''机电'''
    table1.filtered:=true;
      

  5.   

    Table1.Filtered := true;
      Table1.Filter := '年份=''2000'' and 学期=''上'' and 部门=''机电''';
      table1.open;
      

  6.   

    table1.filter:='年份=''2000'' and 学期=''上'' and 部门=''机电''';
    table1.filtered:=true;
      

  7.   

    table1.disablecontrols;
    table1.first;
    while not table1.eof  do
     begin
      if table1.fieldbyname('年份').value=2000 and 
         table1.fieldbyname('学期').value='上'   and
         table1.fieldbyname('部门').value='机电'  then 
      .............//do what you want to do .
      table1.next;
     end;
    table1.enablecontrols;
      

  8.   

    如果我想让filter中 部门的值等于table2.fieldbyname('部门').value
    table2是另一个表,请问怎么写
    我的这句话: form3.table3.filter:='年份=form3.edit3 and 上下半年=form3.combobox and 部门=form3.table1.FieldByName('部门').asstring';
    编译没通过,请问如何解决。
      

  9.   

    str1:= form3.edit3 .text;
    str2:= form3.combobox;
    str3:= form3.table1.FieldByName('部门').asstring';
    form3.table3.filter:='年份=' + ''''+ str1 and ....
      

  10.   

    个人意见:使用table的filter不如使用sql来的方便。
      

  11.   

    我的这句话form3.table3.filter:='年份=' + ''''+str1 +' and '+'上下半年=' + ''''+str2+' and '+ '部门=' + ''''+str3;编译通过了,
    但执行时出现filter语句不正确的被终止,请帮忙分析一下。
      

  12.   

    请教locate()的用法,我实在是太菜了,多谢多谢。
      

  13.   

    请教locate()的用法,我实在是太菜了。多谢多谢。
      

  14.   

    table1.filtered:=false;
    table1.filter:='年份=''2000'' and 学期=''上'' and 部门=''机电''';
    table1.filtered:=true;
    -----------------
    table1.locate('年份','2000',[]);//详细请看帮助
      

  15.   

    你如果非要用table的话, str前后都要加引号
    建议你改用query我的这句话form3.table3.filter:='年份=' + ''''+str1 +' and '+'上下半年=' + ''''+str2+' and '+ '部门=' + ''''+str3;编译通过了,
    但执行时出现filter语句不正确的被终止,请帮忙分析一下。
      

  16.   

    with Table do
      Locate(年份;学期;部门', VarArrayOf(['2000', '上', '机电']), [loPartialKey]);
      

  17.   

    with Table do
      Locate('年份;学期;部门', VarArrayOf(['2000', '上', '机电']), [loPartialKey]);
      

  18.   

    我的Locate语句 form3.table3.Locate('年份;上下半年;部门',VarArrayOf([str1,str2,str3]),[loPartialKey]);
    执行后没有反应,我把它放在Table1AfterScroll事件里了,table1相当于它的主表,请问为何?
      

  19.   

    with Table do
      Locate('年份';'学期';'部门', VarArrayOf(['2000', '上', '机电']), [loPartialKey]);
      

  20.   

    我的Locate语句form3.table3.Locate('年份;上下半年;部门',VarArrayOf([str1,str2,str3]),[loPartialKey]);在程序执行以后没有反应我把它放在Table1AfterScroll事件中,是想当table1中的部门一变,table3中自动找到
    相对应的记录,请问问题出现在哪,谢谢。
      

  21.   

    你自己清不清楚你要做什么,
    到底是定位某一条记录,
    还是筛选出想要的记录locate是定位用的
    Implements a virtual method for searching a dataset for a specified record and makes that record the active record.
      

  22.   

    如果筛选出一条想要的记录用它可以吗
    我实在是不知道怎么办了。
    我开始时用query做的,但搜索出的结果不能修改。用table又问题多多,
    我脑袋有两个大了,过几天就要答辩了,愁啊。那位好心人帮帮我吧。
      

  23.   

    用query吧,
    从多个表中select出的记录要修改的话
    将query.requestlive:= true;
    query.cachedupdates:= true;save之后用applyupdates提交到数据库
      

  24.   

    楼上的方法可以用,但是不知道对不对,现在的Delphi的入门书教的都是些没有的东西,又骗钱有坑人。
    给你举个例子吧,你要付我网费:)
    在窗体上放置一个Query1,和UpdateSql1
    然后Query1连接数据库(不用我教了吧),按以下设置Query1的属性:
    CacheUpdate设置为True
    UpdateObject设置为UpdateSql1
    然后Query1去查询数据,用UpdateSql1去修改数据,
    可以在UpdateSql1控件上点鼠标右键,选择UpdateSql Editor项可以自动写SQL语句,就可以完成你的要求了
    实际上Table完全可以实现你的要求,只是你的基本功太差,好好练练吧。
    如果还是不会用的话,明天12点以后,我的QQ79383778,如果你现在在的话,也可以call我
      

  25.   

    不会啊,用Query做怎么不能修改呢!只要把RequestLive属性设为True就可以了。
    你用Table做的话所有的查询是在你的前台完成的而不是后台,效率会非常低下。
    with query do
    begin
      Close;
      SQL.Add('select * from Table');
      SQL.Add('where 年份 = "2000"‘);
      SQL.Add('and 学期 = "上"');
      SQL.Add('and 部门 = “机电”’);
      Open;
    end;
    肯定没错!