1
   ADOQuerySelect.Close;
    ADOQuerySelect.SQL.Add(' AND (дата_заказа between #'+dat+'# and #'+da+'#)');
    if ComboBox6.Text <> '' then
    begin
    ADOQuerySelect.Parameters.ParamByName('Name').Value := ComboBox6.Text ;
      ADOQuerySelect.SQL.Add(' AND (Наименование = :Name)');
    end;
ADOQuerySelect.Open;

I use Delphi 2007, MS Access. And i dont now how work with parameters. On this code, i have error: parameter Name not found. I tried many other variants of code, but they all not working. I add parameter Name via GUI with datatype ftstring;

0

2 Answers 2

3

Changing SQL in your code clears the existing parameters, so there's no parameter called 'Name' at the time you try to set its value. You then create the Name parameter, but it's too late.

Change the order of your statements:

ADOQuerySelect.Close;
ADOQuerySelect.SQL.Add(' AND (дата_заказа between #'+dat+'# and #'+da+'#)');
if ComboBox6.Text <> '' then
begin
  ADOQuerySelect.SQL.Add(' AND (Наименование = :Name)');
  ADOQuerySelect.Parameters.ParamByName('Name').Value := ComboBox6.Text ;
end;
ADOQuerySelect.Open;

You should be using parameters for all your replacements, BTW. Let the database driver handle conversions and date formats and quoting values and all of that for you.

Sign up to request clarification or add additional context in comments.

Comments

1

In the object inspector ADOQuerySelect should have 'Name' among list of parameters.

You can also use the following code to create the parameter 'Name':

with ADOQuerySelect.Parameters.AddParameter do
begin
  Name := 'Name';
  DataType := ftString;
end;

3 Comments

it is, in object inspector
And is the 'name' in the SQL table?
The following code for table TAB and one parameter name is working: ADOQuerySelect.SQL.Add('INSERT INTO TAB ( name ) '); ADOQuerySelect.SQL.Add(' VALUES (:name) '); ADOQuerySelect.Parameters.ParamByName('Name').Value := ComboBox6.Text ; try ADOQuerySelect.ExecSQL;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.