select 语句用 open即可
其他语句用 EXECSQL
with ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Text:='update....';
execsql;
end;
2. SQL语句带参数
Query1.ParamByName('参数名').DataType;
3 like语句带参数
DataModule1->ADOQueryRef->Close();
DataModule1->ADOQueryRef->SQL->Clear();
DataModule1->ADOQueryRef->SQL->Add("SELECT * FROM tbRefineries WHERE rfName LIKE :par1 AND rfAddress LIKE :par2 AND rfPhone LIKE :par3");
DataModule1->ADOQueryRef->Parameters->ParamByName("par1")->Value="%"+EdtName->Text+"%";
DataModule1->ADOQueryRef->Parameters->ParamByName("par2")->Value="%"+EdtAddr->Text+"%";
DataModule1->ADOQueryRef->Parameters->ParamByName("par3")->Value=("%"+EdtPhone->Text+"%");
No comments:
Post a Comment