Page 1 of 1

eof after select

Posted: Sat 23 Oct 2010 22:55
try
MyQuery1.SQL.Clear;
MyQuery1.SQL.Text := 'SELECT products_id, products_model from products where products_model like "'+ApolloTable1LITM.Value+'"';
//showmessage(MyQuery1.SQL.Text) ;
MyQuery1.Execute;
except
end;
if MyQuery1.Eof then
begin // Neu
MyQuery1.SQL.Text := 'INSERT into products ( '+
'products_model, '+
-------------------------------
Not any value is found - always eof although when I give the select command direct in eg phpmyadmin at least one item is found.

How will be eof involved ?
(earlier I worked with the component of scibit and change now - hard)
Thanks Erich

Sunday 24.10.
I use now my old Components (from scibit) for retrieving the id.
after I try to update a record (Inserting is now ok),
but with update I have same problem. Always get a error and I see the that te sql text is cutted.
MyQuery1.SQL.Text := 'UPDATE products SET ( '+
'products_model = :products_model, '+
....more
'products_orgin = :products_orgin '+
') WHERE :Old_products_id ='+neuID;
MyQuery1.ParamByName('products_model').AsString := x_products_model;
MyQuery1.ParamByName('products_quantity').AsInteger := x_products_quantity;
... more ....
MyQuery1.ParamByName('products_orgin').AsString := x_products_orgin;
try
MyQuery1.Execute;
except

end;

...
are there anywhere examples or tutorials which shows to handle with this parameters (INSERT/UPDATE etc )? (the demo I know - nothing usefull found for coding)
I only need search data, retrieve some data, insert records and update records.

Posted: Mon 25 Oct 2010 13:09
by AndreyZ
Hello,

I cannot reproduce the problem with the Eof property usage. Please check that ApolloTable1LITM.Value contains the correct value you are looking for.
Don't use brackets in the SQL code. Here is the correct example:

Code: Select all

  MyQuery.SQL.Clear;
  MyQuery.SQL.Add('update products set products_model = :products_model, ...more, products_orgin = :products_orgin');
  MyQuery.SQL.Add('where products_id = :products_id');
  MyQuery.ParamByName('products_model').AsString := x_products_model;
  ... more ...
  MyQuery.ParamByName('products_orgin').AsString := x_products_orgin;
  MyQuery.ParamByName('products_id').AsInteger := neuID;
Please take a look at MyDACDemo. MyDACDemo is located in C:\Documents and Settings\All Users\Documents\Devart\\Demos\MyDacDemo on Windows Vista/7 or in \Demos\MyDacDemo on prior versions of Windows.