谢谢

解决方案 »

  1.   

    不好意思,有点错。应该是RequestLive设为True
      

  2.   

    另外:如果在使用SQL中包含Order By则查询结果无法修改
      

  3.   

    dbgrid  的readonly  false
      

  4.   

    optins   dgediting  设置为 true
      

  5.   

    DBGrid1.Readonly:=True;或:Query1.Readonly:=True;
      

  6.   

    表名不确定,通过参数确定,不应该算多表合并把.我是用的Tquery动态查询数据表,然后用dbgrid显示查询结果,并希望能够修改结果,通过点击按钮决定是否保存到数据库中。我试了把query1.requestlive设为true,就可以修改,但是就不可以查询了。如果在程序中查询前加一条语句:query1.requestlive:=false,查询结束后再把该属性设为true还是不行!难道Tquery真的是不中用了?我再查询中用的代码:
    if trim(comboBox2.Text)<>'' then
      begin
          query1.requestlive:=false;
          bujian_index:=combobox2.ItemIndex;
          case bujian_index of
            0 :bujian:='bujian_shell_plate';
            1 :bujian:='bujian_neidibanlie';
            2 :bujian:='bujian_zonghang';
            3 :bujian:='bujian_zonggu';
            4 :bujian:='bujian_leiban';
            5 :bujian:='bujian_zhouban';
            6 :bujian:='bujian_leigu';
            end;     strSql:='select * from '+bujian+' where "xuhao"=:bujianxuhao';
            if query1.Active then query1.Active:=false;
          query1.SQL.Clear;
          query1.SQL.Add(strsql);
          query1.prepare;
          query1.Params[0].AsString:=trim(combobox1.text);
          query1.Active:=true;
          query1.requestlive:=true;
        end;
      

  7.   

    不能查询的原因可能是你的SQL语句:
    strSql:='select * from '+bujian+'where "xuhao"=:bujianxuhao';有错误。
    可以改为:
    strSql:='select * from  '+bujian+' where xuhao='+char(39)+bujianxuhao+char(39);
      

  8.   

    strSql:='select * from '+bujian+' where "xuhao"=:bujianxuhao';
    可以改为:
    strSql:='select * from '+bujian+' where xuhao='+''''+bujianxuhao+'''';
      

  9.   

    你可以改变一个属性就能实现了
    DBGrid1中的options属性的dgEditing值改为true,就可以修改了.
      

  10.   

    RequesLive:=True;
    readonly := false;
    optins--dgediting设为True;
      

  11.   

    query的属性RequesLive设为True;
    readonly := false;