难道一个query只能连接同一个窗体下的数据感知控件,而不能连接其他窗体下的数据感知控件来append和edit? 
我现在就是这个问题续上次问题 为了还事实一个公道,息事宁人,我将代码贴出来供大家分析,我就是这段代码引发的悲剧,当第一打开客户信息表后,新增和修改都可以用,但退出客户信息表后 再进入就有问题了,如果新增就提示 qry_v_cient_info是一个关闭的数据集,按修改 
就弹出一个什么信息都没有的修改客户信息的form。
qry_v_cient_info的LOCK TYPE为:ltBatchOptimistic
procedure TFCient_Info.FormShow(Sender: TObject);//客户信息资料
begin
with qry_V_Cient_Info do
begin
close;
sql.Clear;
sql.Add('SELECT * FROM V_client_Info order by Id');
Open;
end;procedure TFCient_Info.btn3Click(Sender: TObject);//客户信息里退出按钮
begin
qry_V_Cient_Info.Close;
close;
end;procedure TFCient_Info.N1Click(Sender: TObject);//在客户信息中按新增按钮
begin
qry_V_Cient_Info.Append;
Application.CreateForm(TFCient_Info_1,FCient_Info_1);
with FCient_Info_1 do
begin
Caption:='新增客户资料';
btn1.Visible:=True;
dbedtId.ReadOnly:=False;
edtBith.Value:=u_pubvar.gettime(DM.qry_gettime);
edtCreate_date.Value:=u_pubvar.gettime(DM.qry_gettime);
dbedtSumMoney.Text:='0.00';
ShowModal;
end;
end;procedure TFCient_Info.N2Click(Sender: TObject);//在客户信息里按修改按钮
begin
qry_V_Cient_Info.Edit;
Application.CreateForm(TFCient_Info_1,FCient_Info_1);
with FCient_Info_1 do
begin
Caption:='修改客户资料';
btn1.Visible:=False;
dbedtId.ReadOnly:=True;
ShowModal;
end;
end;

解决方案 »

  1.   

    procedure TFCient_Info.btn3Click(Sender: TObject);//客户信息里退出按钮 
    begin 
    下句去掉看看
    //qry_V_Cient_Info.Close; 
    close; 
    end; 
      

  2.   

    你把数据集都放到DM窗体中吧,
    有可能是你把数据集放到此窗体上,窗体关闭时,数据集就FREE了。
      

  3.   

    procedure TFCient_Info.N1Click(Sender: TObject);//在客户信息中按新增按钮 
    begin Application.CreateForm(TFCient_Info_1,FCient_Info_1); 
    with FCient_Info_1 do 
    begin 
    Caption:='新增客户资料'; 
    btn1.Visible:=True; 
    dbedtId.ReadOnly:=False; 
    edtBith.Value:=u_pubvar.gettime(DM.qry_gettime); 
    edtCreate_date.Value:=u_pubvar.gettime(DM.qry_gettime); 
    dbedtSumMoney.Text:='0.00'; 
     
    end;//试试看顺序
    qry_V_Cient_Info.Append; 
    FCient_Info_1.ShowModal;end; 
    另外用EDIT要同时用post