SQL Connection class lazarus / 16-Databases ---------------------------------------------------------------------- goldenfox · 2012-06-07 04:07 Hi everyone, I would like to know if it's possible to make something like the following snippet below? Code: [Select]Type TMyData = class    private      conn       : TSqlConnection;      query      : TSqlQuery;      trans      : TSqlTransaction;      LastErrMsg : string;      DbName     : string;      procedure CancelSelect;      procedure Save;      procedure EndSelect;    public      constructor Create(const aFilename : string); overload;      destructor  Destroy; override;      function    Select : integer;      procedure   QueryString(const aQuery : string);      property    Items : TSqlQuery read Query;      property    LastError : string read LastErrMsg write LastErrMsg;      property    Filename : string read DbName write DbName; end; My problem is every time I create an instance of that class I always encountered "Abstract method called" in TSqlTransaction. Or is there a proper way to do it? Thanks a lot. ---------------------------------------------------------------------- Lacak2 · 2012-06-07 05:24 How looks rest of code, where you assign instance of some class into private member "conn" ? I guess it looks like: conn := TSQLConnection.Create(Self); But TSQLConnection is intended to be ancestor of various descendants for various databases like TPQConnection for PostreSQL, TMSSQLConnection for MS SQL Server, TODBCConnection for ODBC etc. So you must use something like: conn := TPQConnection.Create(Self); or generic: conn := TSQLConnector.Create(Self); etc. ---------------------------------------------------------------------- goldenfox · 2012-06-07 05:50 Thanks for the hint Lacak2. I didn't notice this line. Code: [Select]  //conn := TSqlConnection.Create(nil); { this was causing the error }   conn := TSQLite3Connection.Create(nil); {this one works } I can't use self too because it gives an error incompatible type Code: [Select]conn := TSQLite3Connection.Create(self); { this gives error too } All is well now =) cheers!. ---------------------------------------------------------------------- Leledumbo · 2012-06-07 12:23 QuoteI can't use self too because it gives an error incompatible typeThat's because the argument (the owner) expects a TComponent descendant, where self here refers to your class which doesn't extend TComponent. ---------------------------------------------------------------------- goldenfox · 2012-06-13 04:31 I've tried different db component and only TOracleConnection is giving me this warning: Code: [Select]mydbo.pas(215,46) Warning: Constructing a class "TOracleConnection" with abstract method "LoadBlobIntoBuffer" ---------------------------------------------------------------------- ludob · 2012-06-13 08:27 QuoteConstructing a class "TOracleConnection" with abstract method "LoadBlobIntoBuffer"That means TOracleConnection has no override for LoadBlobIntoBuffer. Since TOracleConnection has no support for blobs/clobs that is not going to cause a problem. ---------------------------------------------------------------------- goldenfox · 2012-06-15 06:02 Quote from: Lacak2 on June 07, 2012, 07:24:39 amHow looks rest of code, where you assign instance of some class into private member "conn" ? I guess it looks like: conn := TSQLConnection.Create(Self); But TSQLConnection is intended to be ancestor of various descendants for various databases like TPQConnection for PostreSQL, TMSSQLConnection for MS SQL Server, TODBCConnection for ODBC etc. So you must use something like: conn := TPQConnection.Create(Self); or generic: conn := TSQLConnector.Create(Self); etc. Thanks is what I'm trying to do. http://lazarus.freepascal.org/index.php/topic,17247.0.html @ludob: thank's for enligthening =)