SURE.. THIS IS MY EXAMPLE ABOUT MYSQL AND SQLDB...MAYBE YOU NEED CHECK MY PERSONAL POST BECAUSE, I ASK THE SAME QUESTIONS ABOUT MYSQL...
I SEND A PERSONAL EMAIL TO HOWARDH, CHECK YOU GMAIL ACCOUNT please, but is the same information like this is
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:
UpdateMode:=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