DBNavigator, Dbgrid_Explain me..! lazarus / 16-Databases ---------------------------------------------------------------------- BlackCat · 2008-07-15 20:43 hi everybody..!! i have a big problem, I check the example "adrees_book" in lazarus Folder, but it use DBF tables/databases,. I was thinking use this components: DBNavigator, DBGrid, SqlQuery, Datasource, MysqlConnection, SqlTransaction,  At the same time,  I can use DBNavigator with the DBGrid and SqlQuery but when I use  for UPDATE,EDIT, Or DELETE,  this shows me a error.: "Operation can't be peroformer on an active dataset " I need use the DGrid and DBEdit with the DBNAvigator ar the same time,for example: look the Mysql table in te DBGrid and change  one register on this moment,.. I Tried use this code from TRYMSQL example from   lazarus wiky.   SQLQuery1.Upda]"]>Blockedde:=upWhereChanged;     SQLQuery1.ApplyUpdates;     SQLTransaction1.Commit;     Showmessage('ddd'); // set read-only and parsesql back to default     SQLQuery1.ParseSQL:=false;     SQLQuery1.ReadOnly:=true;         but nothing happended, and the same error appeared... I read in the forum tha SQLQUERY not allow the UPDATE, EDIT, DELETE, only I'll going crazy about this....!! 1. Is possible use those componets at the same time? or 2. I need download my table in other componens to use UPDATE, EDIT? 3. What about use this:         sqlquery1.sql.text:='select * from mytable LIMIT 5'; //limit in mysql is to see the first 5 records in the table,         sqlquery.open;         made me an error about "LIMIT ..." I check in mysql console first, then I check in Lazarus if is a valid instruction, WHat about this? somebody can help me?? Thanks...!!  BlackCat.. :cry: ---------------------------------------------------------------------- BlackCat · 2008-07-18 17:00 No more about my problem.. I found the answer.... Thanks ---------------------------------------------------------------------- chris.kirkpatrick · 2008-08-06 09:42 I'm very happy that you found an answer, It would be very helpful if you could share your answer with the rest of us! Chris ---------------------------------------------------------------------- anderson5420 · 2008-08-08 04:30 Yes, I second Chris's suggestion here.  I can get everything to work right up to where I want to edit or insert a record (using a a dbGrid and a dbNavigator on a results form). If I don't use any of the above code for the dbNavigator BeforeAction event, no errors but nothing gets written back to the MySQL database. When I try the BeforeAction event handler code, I get the same error "Operation can't be performed on an active dataset." If I close the dataset (sqlquery), the error becomes "Can't perform operation on an inactive dataset"!  So what state of dataset CAN the operation be performed on?  I would just love to see the code that actually works to apply updates and commit them to the underlying database, which is, you know, sort of the whole point! Pat ---------------------------------------------------------------------- BlackCat · 2008-08-18 06:05 SURE.. THIS IS MY EXAMPLE ABOUT MYSQL AND SQLDB... i try explain you how i made my form, ok, sorry my bad english... i 'm using W Vista, and also work in W Xp SP2, using Lazarus 0.9.24 Instalation i don't change anything else... in some first examples about mysql i made, i add mysql.dll, if you have a problem when run your project similar to "project... mysql.dll... not found" you need add in your Project Folder the mysql.dll ok? but in this example, i check and i don't use anymore mysql.dll i forgot why i need it in my first examples First 1.- I made a form using SQLQUERY, SQLTRANSACTION, SQLCONNECTION and DATASOURCE with NAVIGATOR and DBGRID and DBEDIT'S alias ==[7PACK] check the finish this email, this reference 2.-connect all the component except in the SQLQUERY.datasource:=(none) in blank, don't but nothing, ok. 3.-change also in the Slquery properties this values: Upda]"]>Blockedde:=UpWhereChange UsePrimaryKeyAsKey:=true >>(NOTE: IS VERY IMPORTANT ADD A PRIMARY KEY IN YOUR TABLE FROM MYSQL, IS THE REFERENCES TO CHANGE ON EDIT, UPDATE,ETC.IN MYSQL-SQLQUERY, OK?) 4.- in sqlconnection change: Streamedconnected:=true Now, you only need change in the sqlquery EVENTS, i use these events: After(Close,Delete,Edit,Insert,Post) i dont' know what happend with "before" events in sqlquery, with after events work good in my form. 5.-this is the code i use un each events AFTER: procedure TForm1.SQLQuery1AfterDelete(DataSet: TDataSet); begin SQLQuery1.ApplyUpdates; SQLTransaction1.Commit; end; ; procedure TForm1.SQLQuery1AfterPost(DataSet: TDataSet); //DESPUES DE POST begin SQLQuery1.ApplyUpdates; SQLTransaction1.Commit; end; Right??? don't use Navigator.click event, i spend my time, and i can't found the correct solution to use it.. ok? is an advice for you only, add only AfterPost and AfterDelete Events in Slquery and work fine...!! but, i use also dbedit's: 6.- in dbedit's fill in the next properties: datafield:=[your datafield in your table in mysql e.g. mytable(name var(15), addres var(20),...etc,etc ...... primary key (name) )] dbedit1.datafield:=name dbedit1.datasource:=(none) [why?, i use a button using this instructions.... SqlQuery.Close, SqlQuery.sql.Text:="select * from mytable"..., SqlQuery.Open dbedit.DataSource:=datasource1;..... ok? an also work if you add the datasource in design time, but I HAVE A PROBLEM HERE, ABOUT DBEDITS AND MULTIPLES DGRID USING PAGECONTROL.. I ASK YOU AT FINISH] and works..!! ¿Now, Can you help me about the next problem....? Now, my problem about BDEDIT's is because i use multiples Sheet's in the page control with diferents tables, i can't re-use the same Sql,Trans, Connect, Datas... with diferents dbgrid and dbedit's, because the program .exe give me and error about..."can't found name fields in you....etc, etc" i was thinking about that, i think is because the sqlquery don't free the field in the dbedit and don't break the "connection in the ¿buffer?(the relation in execute time)" between the Query-DBedit.. like "persistant connection"... right?? try use [7PACK] in a pagecontrol using in the first sheet one table, and in the second sheet another table, try use the same bdedit's for your tables, put this outside the page control, directly in the form, or in each sheet... ok? how you ever use pagecontrol in delphi?..is similar... TO SOLVE MY PROBLEM I USE multiples [7PACK] for each table in each sheet in the pagecontrol.. but my question is.. what about the Ram?? i am wrong if i use multiples 7PACKS???the conexion is PERMANENT and PERSISTENT with .exe and Mysq with my multiples 7PACKS i use...?? IF YOU KNOW OTHER EXAMPLES, ABOUT MYSQL AN LAZARUS, I FEEL VERY INTERESTING ABOUT THIS, PLEASE CONTACT ME... because, i feel i feel confuse if my personal conclusions are good or bad.. i check a lot of forums in spanish and english about this, but i found only pieces of information about this and allow me make my example and the posibility to explain you and other.. check in lazarus Forum in Lazarus Wiki in Database questions, I'm BlackCat User in the forum.. is all about your questions and my possible solution... Please, if you made or checked Mysql components, said me what do you thing about my "solution" or your opinion. please... Regards... Mrf from Slp, Mexico