delphi+sql做系统,将dbgrid1表中,用鼠标选中一行,这一行数据就可复制转移到dbgird2中
varm,n,x,y:string;beginADOquery1.Close;ADOquery1.SQL.Clear;ADOquery1.SQL.Text:='selec...
var m,n,x,y:string;
begin
ADOquery1.Close ;
ADOquery1.SQL.Clear ;
ADOquery1.SQL.Text:='select yaopin.Kind_no as 药品编号,yaopin.Drug_name as 药品名,yaopin.Guige as 规格,yaopin.Ind_price as 单价 from yaopin ';
ADOquery1.Open ;
m:=ADOQuery1.FieldByName('药品编号').Asstring;
n:=ADOQuery1.FieldByName('药品名').Asstring;
x:=ADOQuery1.FieldByName('规格').Asstring;
y:=ADOQuery1.FieldByName('单价').Asstring;
ADOquery2.Close ;
ADOquery2.SQL.Clear ;
ADOquery2.SQL.ADD('select Bah as 病案号,shoufeiyaopin.Kind_no as 药品编号,shoufeiyaopin.Drug_name as 药品名,shoufeiyaopin.Guige as 规格,shoufeiyaopin.Ind_price as 单价 from shoufeiyaopin where Bah='''+Edit3.Text+'''');
ADOquery2.Open ;
ADOquery2.Edit ;
ADOQuery2.FieldByName('病案号').AsString:=Edit3.Text;
ADOQuery2.FieldByName('药品编号').Asstring:=m;
ADOQuery2.FieldByName('药品名').Asstring:=n;
ADOQuery2.FieldByName('规格').Asstring:=x;
ADOQuery2.FieldByName('单价').Asstring:=y;
ADOquery2.Post ;
end;
以上是我写的语句,可运行起来的结果不对,我想将dbgrid1表中,用鼠标选中一行,这一行数据就可复制转移到dbgird2中,再用鼠标选dbgrid1表中的一行数据,这一行数据就可复制转移到dbgird2中的第二行,以此类推。语句应该怎么修改。急!!! 展开
begin
ADOquery1.Close ;
ADOquery1.SQL.Clear ;
ADOquery1.SQL.Text:='select yaopin.Kind_no as 药品编号,yaopin.Drug_name as 药品名,yaopin.Guige as 规格,yaopin.Ind_price as 单价 from yaopin ';
ADOquery1.Open ;
m:=ADOQuery1.FieldByName('药品编号').Asstring;
n:=ADOQuery1.FieldByName('药品名').Asstring;
x:=ADOQuery1.FieldByName('规格').Asstring;
y:=ADOQuery1.FieldByName('单价').Asstring;
ADOquery2.Close ;
ADOquery2.SQL.Clear ;
ADOquery2.SQL.ADD('select Bah as 病案号,shoufeiyaopin.Kind_no as 药品编号,shoufeiyaopin.Drug_name as 药品名,shoufeiyaopin.Guige as 规格,shoufeiyaopin.Ind_price as 单价 from shoufeiyaopin where Bah='''+Edit3.Text+'''');
ADOquery2.Open ;
ADOquery2.Edit ;
ADOQuery2.FieldByName('病案号').AsString:=Edit3.Text;
ADOQuery2.FieldByName('药品编号').Asstring:=m;
ADOQuery2.FieldByName('药品名').Asstring:=n;
ADOQuery2.FieldByName('规格').Asstring:=x;
ADOQuery2.FieldByName('单价').Asstring:=y;
ADOquery2.Post ;
end;
以上是我写的语句,可运行起来的结果不对,我想将dbgrid1表中,用鼠标选中一行,这一行数据就可复制转移到dbgird2中,再用鼠标选dbgrid1表中的一行数据,这一行数据就可复制转移到dbgird2中的第二行,以此类推。语句应该怎么修改。急!!! 展开
2个回答
展开全部
你在dbgrid1的onclick事件中将ADOQuery1的值赋给ADOQuery2,并且ADOQuery2增加记录时按楼上说的将edit改为append
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询