CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
山寨机中的战斗机! 程序优化工程师到底对IT界有没有贡献
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Delphi >  数据库相关

adoquery用UPDATE更新后值为NULL,请指教!(急)

楼主bupt_tangxuan(我爱八神庵)2005-07-26 12:38:18 在 Delphi / 数据库相关 提问

procedure   TForm3.Button1Click(Sender:   TObject);  
  var   opwd,npwd,userid,pwd:string;  
  begin  
  opwd:=edit1.Text;  
  npwd:=edit3.Text;  
  userid:=staff_id;  
  pwd:=opwd;  
  if   edit2.text<>edit3.Text   then   begin  
  showmessage('新密码两次输入不匹配,请验证后重新输入');  
  edit1.Text:='';  
  edit2.Text:='';  
  edit3.Text:='';  
  edit1.SetFocus;  
                                                                  end  
  else  
  begin  
  with   adoquery1   do   begin  
  close;  
  sql.Clear;  
  sql.Add('select   *   from   staff   where   userid=:userid   and   pwd=:pwd');  
  parameters.ParamByName('userid').Value:=userid;  
  parameters.ParamByName('pwd').Value:=pwd;  
  active:=true;  
  execsql;  
  open;  
  if   recordcount>0   then     begin  
  close;  
   
  try  
  sql.Clear;  
  sql.Add('update   staff   set   pwd=:npwd   where   userid=:userid');//此处为疑问点  
  parameters.ParamByName('userid').Value:=userid;  
  execsql;  
  edit4.Text:=npwd;  
  showmessage('密码更改成功');  
  except  
  showmessage('网络错误,密码更改失败,请检查网络');  
  end;  
  end  
  else  
  showmessage('密码错误');  
  form3.Close;  
   
                                      end;  
  end;  
  end;  
   
  运行后提示‘密码更改成功’,但查询数据库PWD的值却是NULL,请高手指教。 问题点数:100、回复次数:5Top

1 楼zeroxing(胸无半点墨,腰有万贯财;此般理想高,怎奈做不到!)回复于 2005-07-26 13:04:36 得分 80

sql.Add('update   staff   set   pwd=:npwd   where   userid=:userid');//此处为疑问点  
  parameters.ParamByName('userid').Value:=userid;  
   
  还要加上一个  
  parameters.ParamByName('npwd').Value   :=   yourpassword;Top

2 楼ljdzxx(圣域风)回复于 2005-07-26 13:12:10 得分 10

你的代码第1很难看,第2漏洞百出、第3不够严谨  
  仅  
  active:=true;  
  execsql;  
  open;  
  这几句就看出来你对TADOQuery的操作还停留在表层Top

3 楼smiler007(笑一笑)回复于 2005-07-26 13:32:48 得分 10

try  
  SQL.Close;             //加上这句试试  
  sql.Clear;  
  sql.Add('update   staff   set   pwd=:npwd   where   userid=:userid');//此处为疑问点  
  parameters.ParamByName('userid').Value:=userid;  
  execsql;  
   
  另外,对SELECT语句,你只有Open就行了,不要再发什么ExecSQL命令  
  Top

4 楼bupt_tangxuan(我爱八神庵)回复于 2005-07-26 14:10:56 得分 0

多谢诸位指教!我确实是放下很久了,等于重学。一个人摸索的滋味真的很难受  
  往往一个简单的问题要困扰很久,只好上网来求助。  
  多谢   zeroxing(胸无半点墨,腰有万贯财;此般理想高,怎奈做不到!)的指点和诸位的热心回复,问题已经解决。  
  Top

5 楼lrj2005(努力学习中)回复于 2005-07-26 14:31:30 得分 0

执行插入,更新用exesql  
          查询,用open;Top

相关问题

  • 怎麼用ADOQuery更新方法!!!
  • adoquery更新数据库的问题
  • Adoquery的多表更新问题.
  • ADOQuery更新的一个问题
  • 使用Adoquery的批量更新问题
  • update数据更新问题
  • update语句更新不了
  • 请问在数据库中更新时怎样更新为空null
  • Update NULL
  • 一百分讨论一个问题,跟者有分:如何用ADOQuery执行update然后在dbgrid中做到即时更新.

关键词

  • 密码
  • sql
  • npwd
  • userid
  • 指教
  • parambyname
  • execsql
  • pwd
  • edit
  • 更改

得分解答快速导航

  • 帖主:bupt_tangxuan
  • zeroxing
  • ljdzxx
  • smiler007

相关链接

  • Delphi类图书
  • Delphi类源码下载
  • Delphi控件下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo