Recent

Author Topic: Cannot update a record using SQLQuery, Update etc.  (Read 1119 times)

Zvoni

  • Hero Member
  • *****
  • Posts: 2961
Re: Cannot update a record using SQLQuery, Update etc.
« Reply #15 on: March 20, 2025, 02:39:34 pm »
Comment:

When you assign database to a query, the default transaction is used. You don't to have to assign it again, unless you are going to use different transaction.

Your way has no problem. I'm asking simply from curiosity.
Not that i know of.
I always had to connect the 3 (or more) Objects as described in Wiki/Documentation:
Create Connection-Object
Create Transaction-Object (or as many as you need)
Assign Transaction-Object to Transaction-Property of Connection-Object (only one Transaction per Connection?)
Assign Connection-Object to Database-Property of Transaction(s)
Create Query-Object(s)
Assign Transaction-Object to Transaction-Property of Query
Assign Connection-Object to Database-Property of Query
Open Connection
Activate Transaction(s)
Open Query(s)

EDIT: I just looked into the Source-Code of sqlite3conn:
there is no "Default"-Transaction-Object for sqlite3connection, only the Inherited Transaction-Object of its Ancestor TSQLconnection.
and in sqldb (TSQLConnection) i found this snippet
Code: Pascal  [Select][+][-]
  1. procedure TSQLConnection.GetDBInfo(const ASchemaType : TSchemaType; const ASchemaObjectName, AReturnField : string; AList: TStrings);
  2.  
  3. var qry : TCustomSQLQuery;
  4.  
  5. begin
  6.   if not assigned(Transaction) then
  7.     DatabaseError(SErrConnTransactionnSet);
  8.  
If transaction is not Assigned return what??
« Last Edit: March 20, 2025, 03:00:55 pm by Zvoni »
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

egsuh

  • Hero Member
  • *****
  • Posts: 1592
Re: Cannot update a record using SQLQuery, Update etc.
« Reply #16 on: March 22, 2025, 01:10:00 am »
Quote
EDIT: I just looked into the Source-Code of sqlite3conn:
there is no "Default"-Transaction-Object for sqlite3connection, only the Inherited Transaction-Object of its Ancestor TSQLconnection.
and in sqldb (TSQLConnection) i found this snippet

Hmmm..  I'm more accustomed to using components from component palletes.
Generally I drop one database, one transaction, and sqlquery components on Datamodule, and set Transaction's database to Database, and then SQLQuery's database to database.  Then at the object inspector of sqlquery, transaction is set automatically. Not sure when programmed.

I love easy life ^^
« Last Edit: March 22, 2025, 01:22:39 am by egsuh »

 

TinyPortal © 2005-2018