[lazarus] ANSISTRING expected TSTRINGS (trouble)

Michael Van Canneyt michael.vancanneyt at wisa.be
Sun Aug 25 18:17:35 EDT 2002




On Sun, 25 Aug 2002, marius popa wrote:

> i want to run next code (create a Tstrings and then transmit it to a query )
>   tmpquery := TFIBQuery.Create(Self);
>   mysql:=Tstrings.Create();
>   mysql:='Select * from employee';     (*this is the line 152*)
>   tmpquery.SetSQL(mysql);
>
> and this error kill me !!
>
> gtkfireadmin_main_form.pp(152,10) Error: Incompatible types: got "ANSISTRING" expected "TSTRINGS"
>
> but if i put this way (like in delphi )
>
>   tmpquery := TFIBQuery.Create(Self);
>   mysql:=Tstrings.Create();

You cannot create an instance of TStrings, this is an abstract class.
You must create a TStringList:
 mysql:=TStringList.Create();

>   mysql.add('Select * from employee');
>   tmpquery.SetSQL(mysql);
>
> then the program compiles ok but if i run the code (ex when i push a button)
> the i have an AV (An unhandled exception occurred at 0x080BDFAC :
> Abstract method called

This is where you see that the TStrings is abstract.
Normally, the compiler warns you if you try to
create abstract classes, so you should have had a warning.

Michael.







More information about the Lazarus mailing list