[Lazarus] Need some help with UpdateSQL in TSQLQuery and TMySQL50Connection

Howard Lee Harkness howard.lee.harkness at gmail.com
Tue May 27 01:59:02 CEST 2008


Replies below.

On Mon, May 26, 2008 at 5:04 PM, Joost van der Sluis <joost at cnoc.nl> wrote:
> Op maandag 26-05-2008 om 16:47 uur [tijdzone -0500], schreef Howard Lee
> Harkness:
>> Ok, if I run this as-is, I get some interesting errors. First thing I
>> noticed is that when I click on "add" in the DBNavigator, the
>> auto-increment field is not added properly; it's left blank.
>
> That's normal. TSQLQuery caches everything. In fact the record isn't
> made yet, only in memory. So MySQL didn't generate a number yet.

When I click on "post", there is no ZIPID generated, and while the
record looks like it got added, when I exit and restart the program, I
see that nothing actually got inserted. I have to conclude that I'm
leaving out something (probably a "commit"). I also see that deletes
don't actually happen, probably for the same reason, and the 'post'
doesn't generate a 'commit'.

If I recall correctly, back in the days of D3, using BDE, I could
create a simple table editor with a dbgrid, a datasource, and a ttable
(or tquery), and no added code at all. This does not seem to be the
case here, unless I connected a property up incorrectly.

>> Next, when I exit the program, I get a mysterious error message that
>> tells me that I attempted to use a type name as an expression, as
>> reported by procedure DatabaseError in unit db. I get a database error
>> from just loading the program into Lazarus, and then closing Lazarus.
>
> Can you give the literal error-message?

Certainly. The error message I get on exit from Lazarus is: An
exception occurred during deletion of
"SQLTransaction1:TSQLTransaction" Operation cannot be performed on an
active dataset.

I do not get this error when running the program outside the IDE.

The error message I get when exiting the program (in the IDE only) is:
 Project rasised exception class 'EDatabaseError'

On examination of the msg parameter of  Procedure DatabaseError (Const
Msg:String), it reads: Attempt to use a type name as an expression.

Again, I do not see this exception when running the program outside of
the IDE, so I am assuming this is an artifact of the debugger or IDE.

>
> btw: you can use the same transaction for the query and the connection.
> Especially with MySQL, where the transaction-code only contains empty
> stubs.

Ok, that's good to know. Where/how do I invoke "commit" ?

> Joost.
-- 
Howard Lee Harkness
The Celtic Fiddler
www.celtic-fiddler.com



More information about the Lazarus mailing list