procedure TForm5.Button1Click(Sender: TObject);
begin
if dblookupcombobox1.Text='' then
begin
showmessage('请输入标识!!!');
Exit;
end;
id:=Table1.Lookup('identifier',dblookupcombobox1.Text,'identifier');
if edit2.Text<>edit3.Text then
begin
showmessage('两个密码不相同');
exit;
end
else
begin
query1.Close;
query1.SQL.Clear;
query1.SQL.Add('update operatordoc set password='+edit2.Text+'where identifier='+id+'');
query1.ExecSQL;
query1.Open;;
showmessage('密码修改成功!');
edit2.Text:='';
edit3.Text:='';
end;
end;
begin
if dblookupcombobox1.Text='' then
begin
showmessage('请输入标识!!!');
Exit;
end;
id:=Table1.Lookup('identifier',dblookupcombobox1.Text,'identifier');
if edit2.Text<>edit3.Text then
begin
showmessage('两个密码不相同');
exit;
end
else
begin
query1.Close;
query1.SQL.Clear;
query1.SQL.Add('update operatordoc set password='+edit2.Text+'where identifier='+id+'');
query1.ExecSQL;
query1.Open;;
showmessage('密码修改成功!');
edit2.Text:='';
edit3.Text:='';
end;
end;
呵呵,要写成
password='+QuotedStr(edit2.Text)
where前面好像少了一个空格
不过你的问题陨石的答案的可能性大些。
改成
query1.SQL.Add('update operatordoc set password='''+edit2.Text+''' where identifier='''+id+''' ');
这个看看
你试试将password字段名改成其他的如pwd,
另外如果pwd是字符,则语句应改写为
'update operatordoc set password= '''+edit2.Text+''' where identifier='''+id+'''不过最好采用参数法
sql:='update operatordoc set pwd=:pwd where identifier=:id'
query1.Close;
query1.UnPrepare;
query1.SQL.Clear;
query1.SQL.Add(sql);
query1.ParamByName('pwd').AsString:=Edit1.Text;
query1.ParamByName('id').AsString:=Edit2.Text;
query1.Prepare;
query1.ExecSQL;
query1.SQL.Add('update operatordoc set password='''+edit2.Text+'''where identifier='+id+');
不知道为什么,很急!
showmessage('请输入标识!!!');
Exit;
end;
id:=Table1.Lookup('identifier',dblookupcombobox1.Text,'identifier');
if edit2.Text<>edit3.Text then
begin
showmessage('两个密码不相同');
exit;
end
else
begin
query1.Close;
query1.SQL.Clear;
query1.SQL.Add('update operatordoc set pwd='+edit2.Text+' where identifier='''+id+''' ');
query1.ExecSQL;
query1.Open;
showmessage('密码修改成功!');
edit2.Text:='';
edit3.Text:='';
end;
end;
我改成这样之后,执行程序,居然一直出现sql执行(沙漏)标志,没有结果!
begin
if dblookupcombobox1.Text='' then
begin
showmessage('请输入标识!!!');
Exit;
end;
id:=Table1.Lookup('identifier',dblookupcombobox1.Text,'identifier');
if edit2.Text<>edit3.Text then
begin
showmessage('两个密码不相同');
exit;
end
else
begin
query1.Close;
query1.SQL.Clear;
偶觉得应改这里
query1.SQL.Add('update operatordoc set password='''+edit2.Text+''''+' where identifier='''+id+'''');
query1.ExecSQL;
query1.Open;;
showmessage('密码修改成功!');
edit2.Text:='';
edit3.Text:='';
end;
end;
在字符串内的单引号用两个单引号表示,另外where前要有空格否则会合前边的内容连到一起。
query1.Open;
用了ExecSQL就不能open,用open就出错