|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hello!
I'm having troubles with a parameter in my SQL Query: Code:
Select * from A_REGISTER where :fältparameter LIKE :sökparameter (fält= field, sök = search) The searchparameter works, but the fieldparameter doesnt. I assign the values and execute the search this way: Code:
procedure TForm2.Button1Click(Sender: TObject);
begin
if RadioButton1.Checked=true then
query1.ParamByName('fältparameter').AsString := 'Namn';
if RadioButton2.Checked=true then
query1.ParamByName('fältparameter').AsString := 'Kemnamn';
with Query1 do begin
Close;
query1.ParamByName('sökparameter').AsString := '%'+edit1.text+'%';
ExecSQL;
Open;
end;
end;
The weird thing is that if i put an "a" in the edit1box the query returns all the posts in the database. |
|
#2
|
|||
|
|||
|
don't pass the table name as parameter, pass only values.
if RadioButton1.Checked= then csSQL := 'Select * from A_REGISTER where Field1 LIKE :sökparameter if RadioButton2.Checked then csSQL := 'Select * from A_REGISTER where Field2 LIKE :sökparameter |
|
#3
|
|||
|
|||
|
you can't use variant for TableName,fieldName, ViewName, etc.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Delphi Programming > Need help with parameters in SQL Query |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|