使用delphi中adoquery.edit之后,为什么还是增加一条记录而不是修改呢?
F_dairytao.ADOQuerymain.edit;F_dairytao.ADOQuerymain.fieldbyname('BarnName').AsString...
F_dairytao.ADOQuerymain.edit;
F_dairytao.ADOQuerymain.fieldbyname('BarnName').AsString := edit1.Text;
F_newdairy.ADOQueryID.Close;
F_newdairy.ADOQueryID.SQL.Clear;
F_newdairy.ADOQueryID.SQL.Add('select BREEDID from BREED where BREEDNAME ='+quotedstr(combobox1.Text));
F_newdairy.ADOQueryID.Open;
if combobox1.text<>'' then
F_dairytao.ADOQuerymain.fieldbyname('BreedID').AsInteger := F_newdairy.ADOQueryID.FieldByName('BreedID').AsInteger;
F_dairytao.ADOQuerymain.fieldbyname('Birthday').AsDateTime := DateTimePicker1.Date;
F_dairytao.ADOQuerymain.fieldbyname('AnimalID').AsString := edit2.Text;
if RadioButton1.Checked then
F_dairytao.ADOQuerymain.fieldbyname('sex').AsString := RadioButton1.Caption
else
if RadioButton2.Checked then
F_dairytao.ADOQuerymain.fieldbyname('sex').AsString := RadioButton2.Caption ;
if combobox7.text<>'' then F_dairytao.ADOQuerymain.fieldbyname('SireID').AsString:=combobox7.text;
if combobox8.text<>'' then F_dairytao.ADOQuerymain.fieldbyname('DamID').AsString:=combobox8.text;
F_dairytao.ADOQuerymain.Post; 展开
F_dairytao.ADOQuerymain.fieldbyname('BarnName').AsString := edit1.Text;
F_newdairy.ADOQueryID.Close;
F_newdairy.ADOQueryID.SQL.Clear;
F_newdairy.ADOQueryID.SQL.Add('select BREEDID from BREED where BREEDNAME ='+quotedstr(combobox1.Text));
F_newdairy.ADOQueryID.Open;
if combobox1.text<>'' then
F_dairytao.ADOQuerymain.fieldbyname('BreedID').AsInteger := F_newdairy.ADOQueryID.FieldByName('BreedID').AsInteger;
F_dairytao.ADOQuerymain.fieldbyname('Birthday').AsDateTime := DateTimePicker1.Date;
F_dairytao.ADOQuerymain.fieldbyname('AnimalID').AsString := edit2.Text;
if RadioButton1.Checked then
F_dairytao.ADOQuerymain.fieldbyname('sex').AsString := RadioButton1.Caption
else
if RadioButton2.Checked then
F_dairytao.ADOQuerymain.fieldbyname('sex').AsString := RadioButton2.Caption ;
if combobox7.text<>'' then F_dairytao.ADOQuerymain.fieldbyname('SireID').AsString:=combobox7.text;
if combobox8.text<>'' then F_dairytao.ADOQuerymain.fieldbyname('DamID').AsString:=combobox8.text;
F_dairytao.ADOQuerymain.Post; 展开
2个回答
展开全部
1、打开数据库后先指向要修改的记录
2、edit放open后一句
2、edit放open后一句
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
F_dairytao.ADOQuerymain
edit 之前是空记录吧
F_newdairy.ADOQueryID.Open;
if not F_newdairy.ADOQueryID.eof then .....
edit 之前是空记录吧
F_newdairy.ADOQueryID.Open;
if not F_newdairy.ADOQueryID.eof then .....
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询