Recent

Author Topic: Problem with 'Post' in DBNavigator  (Read 18158 times)

yurav

  • Newbie
  • Posts: 3
Problem with 'Post' in DBNavigator
« on: January 31, 2007, 09:17:18 pm »
I'm make simple project in Lazarus 0.9.20 for work in MySQL 4.0. I drop to form follow componet's: TMySQL40Connection, TSQLTransaction, TSQLQuery, TDatasource, TDBGrid and TDBNavigator.
In SQLTransaction set 'Action' property as 'caCommit'. In SQLQuery i write SQL command: 'select * from my_table' and set 'ReadOnly' property as 'False'. After run program i have data from my table in DBGrid, but after change data in table and using DBNavigator button 'Post' i have error 'Operation not allowed, dataset 'SQLQuery1' is not in an edit state'. Where is error? How i can post data to my table?

carlos_oliveira_10

  • Newbie
  • Posts: 6
Re: Problem with 'Post' in DBNavigator
« Reply #1 on: October 11, 2009, 04:02:06 pm »
Hi,

I am creating a form with a dgrid and DBNavigator. When I click 'post' nothing is changed in the DB. what is needed?

I have these functions defined:

datasource1.autoedit = true
dbnavigator.datasource = DataSource1

tk

  • Sr. Member
  • ****
  • Posts: 361
Re: Problem with 'Post' in DBNavigator
« Reply #2 on: October 11, 2009, 06:18:10 pm »
Hi, 0.9.20 is very old version. Pls download a newer one, I recommend the latest snapshot but the official 0.9.28 might work well.
If then still in trouble, you can try my TKDBGrid.

Regards,
Tomas

LacaK

  • Hero Member
  • *****
  • Posts: 691
Re: Problem with 'Post' in DBNavigator
« Reply #3 on: October 12, 2009, 07:38:11 am »
To realy write data you must:
1. Post
2. ApplyUpdates
3. Commit (AFAIK Action property of TSQLTransaction is not implemented, so it has no effect)

carlos_oliveira_10

  • Newbie
  • Posts: 6
Re: Problem with 'Post' in DBNavigator
« Reply #4 on: October 17, 2009, 08:45:57 pm »
Hi,

I am creating a form with a dgrid and DBNavigator. When I click in 'post' nothing is changed in the DataBase. what is needed?

I have these functions defined:

datasource1.autoedit = true
dbnavigator.datasource = DataSource1

with the last version of lazarus i have the same problems. someone help me?

thank you.

tk

  • Sr. Member
  • ****
  • Posts: 361
Re: Problem with 'Post' in DBNavigator
« Reply #5 on: October 17, 2009, 11:35:28 pm »
Try something like this to check the updating first:

Trans := TSQLTransaction.Create(Self);
Trans.DataBase := YourConnection;
SQLQuery := TSQLQuery.Create(Self);
SQLQuery.DataBase := YourConnection;
SQLQuery.ParseSQL = True;
SQLQuery.UsePrimaryKeyAsKey := False;
SQLQuery.SQL.Add := 'SELECT * FROM [yourtable]';
SQLQuery.UpdateMode := upWhereChanged;
SQLQuery.Transaction := Trans;
SQLQuery.Open;
SQLQuery.Edit;
SQLQuery.Fields[0].AsString := 'Modified'; // or the like with your type
SQLQuery.Post;
SQLQuery.ApplyUpdates;

Keep in mind that some things in the fpc database system seem to be very incomplete. E.g. the ODBC seems to support only integer and non-unicode string type for write access (I use it to connect to MSSQL - this way I use connect, read and update).

TK

carlos_oliveira_10

  • Newbie
  • Posts: 6
Re: Problem with 'Post' in DBNavigator
« Reply #6 on: October 18, 2009, 04:34:59 am »
Hi!

Thank you for help but this solution doesn't solve my problem...

Do you know another solution?

Has anyone ever used the DBNavigator?


tk

  • Sr. Member
  • ****
  • Posts: 361
Re: Problem with 'Post' in DBNavigator
« Reply #7 on: October 18, 2009, 11:28:09 am »
But the database updates with my code?

If yes, you just need to adapt the SQLQuery.AfterPost event and call SQLQuery.ApplyUpdates.

TK

carlos_oliveira_10

  • Newbie
  • Posts: 6
Re: Problem with 'Post' in DBNavigator
« Reply #8 on: October 18, 2009, 02:03:35 pm »
But the database updates with my code?

If yes, you just need to adapt the SQLQuery.AfterPost event and call SQLQuery.ApplyUpdates.

TK

Hi,

The DBGrids changed with your code but the database no!

Thank you

tk

  • Sr. Member
  • ****
  • Posts: 361
Re: Problem with 'Post' in DBNavigator
« Reply #9 on: October 18, 2009, 05:07:33 pm »
Is the AfterPost and thus ApplyUpdates called if you press Post?

If yes and still db not updated try that Trans.Commit into AfterPost, after the ApplyUpdates command. This must work then.

Code: [Select]
procedure TMainForm.MyAfterPost(DataSet: TDataSet);
begin
  try
    SQLQuery.ApplyUpdates;
    Trans.Commit;
  except
    on E: Exception do
      MessageBox(Handle, PChar('Problem with updating: ' + E.Message), PChar(Caption), MB_OK);
  end;
end;
« Last Edit: October 18, 2009, 05:10:13 pm by tk »

LacaK

  • Hero Member
  • *****
  • Posts: 691
Re: Problem with 'Post' in DBNavigator
« Reply #10 on: October 23, 2009, 02:34:47 pm »
E.g. the ODBC seems to support only integer and non-unicode string type for write access (I use it to connect to MSSQL - this way I use connect, read and update).
in 2.5.x branch of FPC is added support for additional types of parameters ...

 

TinyPortal © 2005-2018