写法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;
时间: 2024-11-11 21:58:46