在一个自定义的过程中写下如下代码:procedure TNamePwdFrm.UpdateName;
begin
if edtNewName.Text <>'' then
begin
if edtUpdate.Text =edtNewName.Text then
begin
with SSDM.qryAdmin do
try
Prepare;
Open;
SQL.Add('update TABLE_ADMIN set UserName='''+edtNewName.Text+'''');
ShowMessage('修改成功!')
finally
Close;
Unprepare;
end;
end;
end
else //错误信息:";"expected but 'else'found
ShowMessage('输入的用户名不一致!');
end
else //错误信息:"."expected but ';'found
ShowMessage('用户名不能为空!');
end;
这是怎么回事???
begin
if edtNewName.Text <>'' then
begin
if edtUpdate.Text =edtNewName.Text then
begin
with SSDM.qryAdmin do
try
Prepare;
Open;
SQL.Add('update TABLE_ADMIN set UserName='''+edtNewName.Text+'''');
ShowMessage('修改成功!')
finally
Close;
Unprepare;
end;
end;
end
else //错误信息:";"expected but 'else'found
ShowMessage('输入的用户名不一致!');
end
else //错误信息:"."expected but ';'found
ShowMessage('用户名不能为空!');
end;
这是怎么回事???
放在prepair前面
begin
if edtNewName.Text <>'' then
begin
if edtUpdate.Text =edtNewName.Text then
begin
with SSDM.qryAdmin do
try
Prepare;
Open;
SQL.Add('update TABLE_ADMIN set UserName='''+edtNewName.Text+'''');
ShowMessage('修改成功!')
finally
Close;
Unprepare;
end;
// end; //这句是多余的
end
else //错误信息:";"expected but 'else'found
ShowMessage('输入的用户名不一致!');
end
else //错误信息:"."expected but ';'found
ShowMessage('用户名不能为空!');
end;
begin
if edtNewName.Text <>'' then
begin
if edtUpdate.Text =edtNewName.Text then
begin
with SSDM.qryAdmin do
begin //add
try
Prepare;
Open;
SQL.Add('update TABLE_ADMIN set UserName='''+edtNewName.Text+'''');
ShowMessage('修改成功!')
finally
Close;
Unprepare;
end;
end;
end
else //错误信息:";"expected but 'else'found
ShowMessage('输入的用户名不一致!');
end
else //错误信息:"."expected but ';'found
ShowMessage('用户名不能为空!');
end;
而且你的更新没有指定条件, 会不会有问题
SQL.Add('update TABLE_ADMIN set UserName='''+edtNewName.Text+'''');
ExecSQL;
qryAdmin.close;
qryAdmin .sql.clear;
qryAdmin .sql.text:='update TABLE_ADMIN set UserName='+''''+trim(edtNewName.Text)+'''';
qryAdmin.execsql;
qryAdmin .close;