数据集sql语句写法

写法1:直接把变量值包含在sql的表达式中;

with frmDataPool.qry用户账号表 do
 begin
  Close;
  SQL.Text:='select * from 用户账号表 where admid = ' + QuotedStr(edtAdmid.Text) + ' AND admps = ' + QuotedStr(edtAdmps.Text);
  Open;
 end;

写法2:用参数

with frmDataPool.qry用户账号表 do
begin
  Close;
  SQL.Text:='select * from 用户账号表 where admid = :admid  AND admps =:admps ';  
  Parameters.ParamByName('admid').Value:=edtAdmid.Text; //为admid参数赋值; 
  Parameters.ParamByName('admps').Value:=edtAdmps.Text; //为admps参数赋值;
  Open; 
end;

  

 

posted @ 2017-05-19 17:42  delphi学习交流吧  阅读(394)  评论(0编辑  收藏  举报