Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-07

Some information about DBNavigator and DBGrid single applications

7 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Arí Ricardo Ody

I built a single application to browse and update a SQLite database that have 1 table with 2 columns: num and name I inserted 2 lines in the table begin my tests.

The application consists in a DBNavigator and DBGrid. When I ran the program the grid appears and the 2 lines appear normally in the grid. Everything seems to be fine.

Then I try to include a new line in the grid by click on "+"(insert) button of the DBNavigator. It appears a new line in the grid. I type a number and name and click the "post" button of the DBNavigator. The grid appears now with 3 lines. I repeat the operation and the grid appears with 4 lines. As expected.

In this moment I click the "refresh" button of the DBNavigator. Surprise! I receive the original grid with the 2 lines I inserted originally. E.g., the insertions don't occurs in the database although the new lines appear in the grid before I click the refresh button.

There was a SQLite3 connection, a SQLQuery, a Datasource and a SQLTransaction. Are these components plus DBNavigator and DBGrid data-aware components? It seems that they don't.

Other question: After I click the "+" button in the DBNAvigator and type the newline, how can I get in my code the values typed in the new line?

Greetings from Sao Paulo - Brazil

Ricardo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110726/10c18a93/attachment-0001.html>

Reply by email

William Oliveira Ferreira
to Arí Ricardo Ody

I think you shoud use apllyUpdates from your dataset after post, no? ________________________________
William de Oliveira Ferreira
Bacharel em Sistemas de Informa??o

2011/7/26 "Ar? Ricardo Ody"

Show quoted text 37 lines
I built a single application to browse and update a SQLite database that have 1 table with 2 columns: num and name I inserted 2 lines in the table begin my tests. The application consists in a DBNavigator and DBGrid. When I ran the program the grid appears and the 2 lines appear normally in the grid. Everything seems to be fine. Then I try to include a new line in the grid by click on "+"(insert) button of the DBNavigator. It appears a new line in the grid. I type a number and name and click the "post" button of the DBNavigator. The grid appears now with 3 lines. I repeat the operation and the grid appears with 4 lines. As expected. In this moment I click the "refresh" button of the DBNavigator. Surprise! I receive the original grid with the 2 lines I inserted originally. E.g., the insertions don't occurs in the database although the new lines appear in the grid before I click the refresh button. There was a SQLite3 connection, a SQLQuery, a Datasource and a SQLTransaction. Are these components plus DBNavigator and DBGrid data-aware components? It seems that they don't. Other question: After I click the "+" button in the DBNAvigator and type the newline, how can I get in my code the values typed in the new line? Greetings from Sao Paulo - Brazil Ricardo -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110726/cf08b147/attachment.html>

Reply by email

Felipe Monteiro de Carvalho
to William Oliveira Ferreira

2011/7/26 William Oliveira Ferreira :

I think you shoud use apllyUpdates from your dataset after post, no?

I think that the updates should apply automatically. Or at least there should be a configuration to make it work like that, but I don't remember which one...

Felipe Monteiro de Carvalho

Reply by email

Arí Ricardo Ody

In the DBNavigator1Click I include the lines:

 if Button = nbPost then
 SQLQuery1.ApplyUpdates(-1);

The results remain unchanged. I repeat the process described below and everythings remain the same.

I suppose this if command attends your suggestion, William. Is this right?

Thanks

Ricardo

Earlier message 31 lines
----- Original Message ----- From: William Oliveira Ferreira Sent: 07/26/11 12:08 PM To: Lazarus mailing list Subject: Re: [Lazarus] Some information about DBNavigator and DBGrid single applications I think you shoud use apllyUpdates from your dataset after post, no? ________________________________ William de Oliveira Ferreira Bacharel em Sistemas de Informa??o 2011/7/26 "Ar? Ricardo Ody" < > I built a single application to browse and update a SQLite database that have 1 table with 2 columns: num and name I inserted 2 lines in the table begin my tests. The application consists in a DBNavigator and DBGrid. When I ran the program the grid appears and the 2 lines appear normally in the grid. Everything seems to be fine. Then I try to include a new line in the grid by click on "+"(insert) button of the DBNavigator. It appears a new line in the grid. I type a number and name and click the "post" button of the DBNavigator. The grid appears now with 3 lines. I repeat the operation and the grid appears with 4 lines. As expected. In this moment I click the "refresh" button of the DBNavigator. Surprise! I receive the original grid with the 2 lines I inserted originally. E.g., the insertions don't occurs in the database although the new lines appear in the grid before I click the refresh button. There was a SQLite3 connection, a SQLQuery, a Datasource and a SQLTransaction. Are these components plus DBNavigator and DBGrid data-aware components? It seems that they don't. Other question: After I click the "+" button in the DBNAvigator and type the newline, how can I get in my code the values typed in the new line? Greetings from Sao Paulo - Brazil Ricardo --

Reply by email

Arí Ricardo Ody

Note that if you tru to click the "+" plus "V"(post) the screen appears with the new line, but if you click the refresh button the screen returns to the initial state, e.g. 2 lines on the SQLite tabel.

There is some lines of code that I transformed in comments. The idea was insert data manually in the table when the user clicks "V"(post). I can't determine de right way of mount the INSERT command and execute it.

The project is upload in

http://www.4shared.com/file/qRYz5z9t/testes_sqllite.html

I'll wait your advices and fixes. Excuse me for my delay. I remain all day away from computers.

[ ]

Ricardo

Earlier message 10 lines
----- Original Message ----- From: Felipe Monteiro de Carvalho Sent: 07/27/11 08:26 AM To: Lazarus mailing list Subject: Re: [Lazarus] Some information about DBNavigator and DBGrid single applications Could you attach your project somewhere? If you have nowhere to host it, then maybe open a topic in the forum and attach there. -- Felipe Monteiro de Carvalho -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110728/705e8f8c/attachment-0001.html>

Reply by email

Felipe Monteiro de Carvalho
to Arí Ricardo Ody

Ummm, that project uses Connection, Query and Transaction, which are components which I never use. Are you sure that you need those more complex components for your project?

I always use datasets, and your program worked fine for me when I added the following TSqlite3Dataset:

  object Datasource1: TDatasource
    DataSet = Sqlite3Dataset1
    left = 512
    top = 176
  end
  object Sqlite3Dataset1: TSqlite3Dataset
    FileName = '/Users/felipe/Programas/testes_sqllite/dbteste'
    SaveOnClose = True
    TableName = 'teste'
    Active = True
    left = 426
    top = 41
  end

Note that the properties Active and SaveOnClose need to be set to True. I also added two fields to the dataset of type unknown.

I build that following the instructions found here:

http://wiki.lazarus.freepascal.org/Lazarus_Database_Tutorial#How_To_Use_.28Basic_Usage.29

Clearly something is missing to save the database in the original example. Here is the connection components layout in case someone wants to see without downloading the 7z file:

  object SQLite3Connection1: TSQLite3Connection
    Connected = True
    LoginPrompt = False
    DatabaseName = 'c:\temp\dbteste'
    KeepConnection = False
    Transaction = SQLTransaction1
    LogEvents = []
    Options = []
    left = 512
    top = 64
  end
  object SQLQuery1: TSQLQuery
    Database = SQLite3Connection1
    Transaction = SQLTransaction1
    ReadOnly = False
    SQL.Strings = (
      'select * from teste'
    )
    Params =
    left = 512
    top = 120
  end
  object SQLTransaction1: TSQLTransaction
    Active = True
    Action = caNone
    Database = SQLite3Connection1
    left = 512
    top = 240
  end
Felipe Monteiro de Carvalho

Reply by email