![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
Назначение параметров в ADO, как правильно?
Kolan © (2007-12-26 14:13:00)Здравтсвуйте,
У меня есть ADODataSet, правильно ли я назначаю параметр:
DataSet.Parameters.FindParam('LPUID').Value := ALPUID;
?
Kolan (2007-12-26 14:21:00) [21]
> это GUID?
Нет, это непередаваемая игра слов:
LPU лечебно профилактическое уреждение. ID Identifier
Kolan (2007-12-26 14:19:00) [22]> а не работает, что-ли?
Неа, грит:
Invalid operator for data type. Operator equals modulo, type equals varchar.
Вот весь код:
var
DataSet: TADODataSet;
begin
DataSet := TADODataSet.Create(nil);
DataSet.Connection := DBConnection;
DataSet.CommandText :=
'SELECT NMLPU, CDLPU, CDLPU_U'+#13#10
+'FROM SLLPU'+#13#10
+'WHERE'+#13#10
+'((:LPUID = '') OR (Upper(CDLPU_U) LIKE Upper(:LPUID)+''%''))'+#13#10
+'AND ((:LPUName = '') OR (Upper(NMLPU) LIKE Upper(:LPUName)+''%''))'+#13#10
+'ORDER BY NMLPU';
DataSet.Parameters.FindParam('LPUID').Value := ALPUID;
DataSet.Parameters.FindParam('LPUName').Value := ALPUName;
DataSet.Open;
Result := DataSet;
end;
если убрать параметры из запроса и подставить '', то работает.
Ega23 (2007-12-26 14:18:00) [23]Обрати внимание
FindParam
Note: FindParam operates with the name of a parameter as it appears in an SQL statement or stored procedure, not the Name property of a TParameter object. The two ways of referring to a parameter should not be confused.
ParamByName
Note: ParamByName operates with the name of a parameter as it appears in an SQL statement or stored procedure, not the Name property of a TParameter object. The two ways of referring to a parameter should not be confused.
clickmaker (2007-12-26 14:15:00) [24]а не работает, что-ли?
это GUID?
Palladin (2007-12-26 14:14:00) [25]да