That should clear any misunderstandings you might have if not then ask more questionsSorry!
Taaz...I wish you'd managed to get this diagram in the FPC\Lazarus wiki! It helps a lot. (http://forum.lazarus.freepascal.org/index.php?topic=19431.0 (http://forum.lazarus.freepascal.org/index.php?topic=19431.0)) . EXCEPT....SQL3LiteConnection has the property 'Transaction', which you can (and must?) specify to an SQLTransaction object. BUT, you can only choose one SQLTransaction per connection. But your diagram shows two SQLTransactions for one connection?
SQLTransaction1 and SQLTransaction2 can both be set to SQLite3Connection, but SQL3LiteConnection can only have one SQLTransaction. So I am still confused.
I think I simplified as much as possible but here goes again.
(NOTE: Others users struggling...be advised there is a good (but still quite confusing) explanation here http://wiki.freepascal.org/SQLdb_Programming_Reference (http://wiki.freepascal.org/SQLdb_Programming_Reference) )
Basically, I have one database with 5 tables in it. My program has 5 tabs in it. Each tab is responsible for putting data in and reading from the corresponding table of the database. So Tab2 = Table2. All I want to achieve is for the data in Tab2 or Tab3 to show the data from the table of Table2 or Table3. As you can see in the screenshot of my database form, I now have two SQLQueries, 2 Transactions, and two datasources with one SQLite3Connection. I'd like all the Components1 for one tab form of my program to deal with TableX, and all the Components2 for the second tab form of my program to deal with TableXX and so on.
And what I really need to find is a really simple (like an explanation for a child) explanation of how these 4 elements all bind together. And how you can use them to query ONE database with SEVERAL tables and have the results of those table queries output to different forms. This must be what most people do with them, surely?
The full code, if it helps people see the wider context of what I am doing, is here : https://github.com/tedsmith/quickhash/blob/v3Branch/dbases_sqlite.pas (https://github.com/tedsmith/quickhash/blob/v3Branch/dbases_sqlite.pas)erm sorry missed this one I'll download the project and try it, probably tomorrow.
Taaz...many many thanks for the demo! I've had a quick look before bed (which was fatal!) but I'll look closer when I have more time. It certainly helps! I need to take some time to see how you have linked those components together. It's certainly more concise than my system.fatal? you killed a squirel with your screams or something :P
If you do get time to check out what I've done, I'd very much welcome your guidance. You'll no doubt spot lots of areas to not only fix my issue but probably offer advice on best practice. As I say, I am new to the whole DB interaction so following online guidance fairly blindly.
Ha...I meant because once you start looking at something, before you know it, and hour has passed!I just downloaded everything from your repository (https://github.com/tedsmith/quickhash/tree/v3Branch (https://github.com/tedsmith/quickhash/tree/v3Branch)). I can see the one dbgrid in the main form only one sqlquery in the frmsqlitebases form. assuming that everything compiles correctly what I have to do to see the problem? Keep in mind I'm on windows if that plays any role.
So I've spent some time looking at your example, and excellent as it is, I am still unclear how the same dataconnection is enabling two different grid displays to be active at the same time.
project1.lpr(10,10) Fatal: Cannot find lazdbexport used by project1. Check if package lazdbexport is in the dependencies of the Project Inspector.Yes, I did install lazdbexport. But you might want to add lazdbexport as dependency in your project manager so it's mandatory to install it and the path will be included automatically.
dbases_sqlite.pas(718,2) Fatal: Cannot open include file "dbases_sqlite.lrs"on the line
[FORMS.PP] ExceptionOccurred
Sender=EClassNotFound
Exception=Class "TStringGrid" not found
Stack trace:
$0045AE77
$00459017
$004595B2
$004541CB
$0045A8EA
$004DAF96
$004DADC9
$004DA118
$0041D8E3
$0041D7CC
$0041FC78
$004268F6
TApplication.HandleException Class "TStringGrid" not found
Stack trace:
$0045AE77
$00459017
$004595B2
$004541CB
$0045A8EA
$004DAF96
$004DADC9
$004DA118
$0041D8E3
$0041D7CC
$0041FC78
$004268F6
Why are there {$I xxxxx.lrs} lines?I don't know...the project was originally started in 2011 when I had even less of an idea of what I was doing than now! So I really don't know, but it was started with a version of Lazarus from 2011.
Yes, that worked. I removed ALL the .lrs includes and replaced them with the {$R under implementation.yes this is one of the clean ups that needs to be done. But I'm going to leave it so gizmo can do it as a learning experience.
Why are there {$I xxxxx.lrs} lines?Yes there was a time where resource files where not supported in linux/macos and other *nix OS, only windows has native support for them, lazarus used its own resource management as you might notice the files are loaded on the units initialization section from the exe not when the form is instantiated. Then the FPC team build their own resource compiler that gave them the ability to use them in all supported OSes and the lrs file was phased out, some old application might still use them mostly as a consequence of a "if it is not broken don't fix it" attitude.
Did a very old version of Lazarus once work that way?
I also noticed all the forms are not included in the Project Manager. So I can't switch to them easily with Ctrl+F12.yeah that is a bit of a problem but it only has a hand full of forms so not a big deal.
Bear in mind that when I said above "I have two data sources and two sql queries " etc, the additions are not in that git repository. That said, even with the additions on my local working folder the behaviour is still the same. I mention it just so you don't go looking for two instances and thinking "he said he has two but he only has one". The point is that the version in git behaves the same way as my local non git committed version. I was just trying something out after studying your example and decided to just try and separate it but the problem persist
QuoteYes, that worked. I removed ALL the .lrs includes and replaced them with the {$R under implementation.
yes this is one of the clean ups that needs to be done. But I'm going to leave it so gizmo can do it as a learning experience.
So even if I had a secondary SQLQuery and DataSource and use those for the second display grid (UpdateGridCOPYTAB) I still have the same problem. Because I also assumed that was the problem initially, which is why I tried adding them. But when I realised they didn't work (because it seems to wipe out the data in the first DBGrid),The problem is not the same anymore. You first problem was that the content was the same.
I'll have to read up more on that - all the demo's show using commit so I'd never heard of commitretaining.In most demos the dataset can be closed after committing to the database. So a commit is sufficient.
CommitRetaining commits an active transaction. The changes will be irreversably written to the database.
After this, the transaction is still active. To commit data and deactivate the transaction, execute Commit instead.
The only thing that has confused me is this : if I remove all the SQLQuery1.Close statements, none of my right click options work. For example, sort by filename, sort by path etc. The grid just stays as it is displayed originally. Yet if I put them back in, they all work again. So I'm confused by that. But I guess I need to read up more on it or its an issue for another thread.You have this in the popup menu:
Sorry for the delay in replying RVK. It took me a few evenings to progress on a few areas and I attempted to incorporate most of your suggestions.That sounds like you renamed them from outside the IDE ee explorer and you did not change the unit name inside the code. the file name and then unit name must be the same, or better yet open the unit in the IDE and select file\save as and when you are asked to delete the old unit say yes.
The only one that caused me a problem and resulted me having to resrot to a backup from the day before was changing the names of the various units and forms. I agree with you; it would be an improvement, but Lazarus kept reporting that I was trying to use "an illegal unit name" (or "an illegal form name", or something...it was a few days ago now). So I gave up on that one. But I think most of your other suggestions have been incorporated.
As for the apparant missing pas files and the lazdbexport not being in the dependancies...that still confuses me. They are there in the git repository and when I load it on my system, they are all listed in the Project Inspector.that sounds like you two are looking at different applications. You are opening the application1.lpi and rvk opens the one with the "linux" in its name.
that sounds like you two are looking at different applications. You are opening the application1.lpi and rvk opens the one with the "linux" in its name.Wait, there is an application1.lpi %) I only found one .lpi file in https://github.com/tedsmith/quickhash/tree/v3Branch and that was project1_linux.lpi.