本人现在想做一个修改密码的程序,就是输入姓名后,再输入更改后的密码,就能在数据库中显示出来,
with adotable1 do
adotable1.Open;
if adotable1.Locate('ID',edit3.Text,[LoPartialKey]) then
begin
adotable1.Edit;
adotable1.Delete;
end;
try
adotable1.Append;
adotable1.FieldByName('ID').AsString:=trim(edit3.Text);
adotable1.FieldByName('Name').AsString:=trim(edit1.Text); showmessage('恭喜,您的信息已经修改成功!');
except
showmessage('数据库链接出错!');
end;
adotable1.Post;这个是我现在编完的程序,但是系统老是提示adotable1.FieldByName('Name').AsString:=trim(edit1.Text);有错误,要是注释的话,虽然能修改,但在数据库中显示不出来,请亲们帮忙一下喽!急要!
with adotable1 do
adotable1.Open;
if adotable1.Locate('ID',edit3.Text,[LoPartialKey]) then
begin
adotable1.Edit;
adotable1.Delete;
end;
try
adotable1.Append;
adotable1.FieldByName('ID').AsString:=trim(edit3.Text);
adotable1.FieldByName('Name').AsString:=trim(edit1.Text); showmessage('恭喜,您的信息已经修改成功!');
except
showmessage('数据库链接出错!');
end;
adotable1.Post;这个是我现在编完的程序,但是系统老是提示adotable1.FieldByName('Name').AsString:=trim(edit1.Text);有错误,要是注释的话,虽然能修改,但在数据库中显示不出来,请亲们帮忙一下喽!急要!
SetDataSourceStr向表中写入数据(自定义函数)
SetDataSourceStr从表中读出数据(自定义函数)
if Edit1.text<>GetDataSourceStr3(CustomersDB.DataSource21,'²Ù×÷Ô±',OperateName,'ÃÜÂë') then
if Application.MessageBox(' ÔʼÃÜÂëÓÐÎó£¬ÖØÐÂÊäÈ룡 ',
PChar('¾¯¸æ' ),
MB_OK + MB_ICONWARNING) = IDOK then
begin
Edit1.text:='';
exit;
end;
if Edit2.text<>Edit3.text then
if Application.MessageBox(' ÐÂÃÜÂ벻ͬ£¬ÖØÐÂÊäÈ룡 ',
PChar('¾¯¸æ' ),
MB_OK + MB_ICONWARNING) = IDOK then
begin
Edit2.text:='';
Edit3.text:='';
exit;
end;
if (Edit2.text='') or (Edit3.text='') then
if Application.MessageBox(' δÌîÐÂÃÜÂ룬ÖØÐÂÊäÈ룡 ',
PChar('¾¯¸æ' ),
MB_OK + MB_ICONWARNING) = IDOK then
begin
Edit2.text:='';
Edit3.text:='';
exit;
end;
SetDataSourceStr(CustomersDB.DataSource21,'²Ù×÷Ô±',OperateName,'ÃÜÂë',Edit2.text);
Close;
if Application.MessageBox(' Íê³ÉÃÜÂë±ä¸ü£¡ ',
PChar('ÐÅÏ¢' ),
MB_OK + MB_ICONINFORMATION) = IDOK then ;
为什么用with adotable1 do,用了之后没有begin和end.
adotable1.Delete;前不需要adotable1.Edit;
adotable1.Post;应写在try里。
不需要删除再添加,直接修改就可以。
begin
Open;
if Locate('ID',trim(edit3.Text),[LoPartialKey]) then
Edit
else
Append;
FieldByName('ID').AsString:=trim(edit3.Text);
FieldByName('Name').AsString:=trim(edit1.Text);
try
Post;
except
showmessage('数据库链接出错!');
exit;
end;
showmessage('恭喜,您的信息已经修改成功!');
end;