Recent

Author Topic: SQLQuery & InsertSQL Problem  (Read 5155 times)

antonio.mchelangeli

  • Newbie
  • Posts: 2
SQLQuery & InsertSQL Problem
« on: March 28, 2012, 01:20:16 pm »
Hi,
in the attachment i post the little program that update a firebird database named prova.fdb with the dbgrid.
When i add a new record and press post in the navigator bar the record is added but if i press then refresh button in dbnavigator the record dissolves...

why???
Where is the my error???
 Sorry for the english i am italian

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: SQLQuery & InsertSQL Problem
« Reply #1 on: March 28, 2012, 01:33:39 pm »
Going to have a look.

Before that: you know there's a wiki page (SQLDB Tutorial1) with examples? Also a wiki page explaining insertsql etc?
Second: what Lazarus version? Operating system? Firebird version? Assuming you're using Firebird embedded here? Note that FreePascal Windows x64 doesn't seem to work well with Firebird embedded... you might want to try with x86/32 bit version.
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: SQLQuery & InsertSQL Problem
« Reply #2 on: March 28, 2012, 02:17:21 pm »
Sorry, no time right now... might get back to it..
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: SQLQuery & InsertSQL Problem
« Reply #3 on: March 28, 2012, 02:53:48 pm »
Whatever you do in the dbgrid is in memory. You need to call ApplyUpdates to send them to the database. If you want every record sent to the database when posted, create an AfterPost event handler for SQLQuery1 and call SQLQuery1.ApplyUpdates.
You'll also need to commit the transaction if you want the changes to the database to be permanent.

Lacak2

  • Guest
Re: SQLQuery & InsertSQL Problem
« Reply #4 on: March 28, 2012, 02:55:04 pm »
Yes as Ludo wrote. Missing:

sqlquery1.ApplyUpdates and
SQLTransaction1.Commit[Retaining]

See:
http://wiki.freepascal.org/SQLdb_Tutorial1#Editing_data_using_the_grid

antonio.mchelangeli

  • Newbie
  • Posts: 2
Re: SQLQuery & InsertSQL Problem
« Reply #5 on: March 28, 2012, 07:42:25 pm »
Going to have a look.

Before that: you know there's a wiki page (SQLDB Tutorial1) with examples? Also a wiki page explaining insertsql etc?
Second: what Lazarus version? Operating system? Firebird version? Assuming you're using Firebird embedded here? Note that FreePascal Windows x64 doesn't seem to work well with Firebird embedded... you might want to try with x86/32 bit version.

Lazarus Version : Lazarus 0.9.30.4
Operating system : Windows 7 32 bit
Firebird version : Firebird 2.1 server classic

Thanx
« Last Edit: March 28, 2012, 08:03:48 pm by antonio.mchelangeli »

 

TinyPortal © 2005-2018