You shouldn't define the columns in a TDBGrid.
This is not done. The user may click e.g. 'Table "Eventlist" ' and "start from date "1.1.2023" '
And I generate the query which displays this choice in the DBGrid.
The trick is do be done if the chooses one of those choices e.g.:
e.g. 'Table "Newslist" ' and "start from date "1.2.2023" ' (different table!)
Then the Select-statement has to be changed. This is done nicely, the DBGrid is rewritten.
Never the less, the user-changes do only work, if the first table is chosen. The first table is the one, which helped me to generate the SQL-statements at desing-time. As I adjust the select-statement at runtime to point at the different table and the other SQL statements not, - they remain pointing at the first table and do nothing more as they have learnt at design-time.
This is not very surprising.
The point is, - how to change this best?
Another way would be, not to change the SQL-statements but the Dataset.
(forgive me, I keep mixing up datasource, dataset nothing helps)
Yes, if you use TIBDataset (or TIBQuery + TIBUpdateSQL combo) you need to set the UPDATE and DELETE yourself.
This "combo" I found in the manual and was excited about.
Not sure, if I need a DELETE. Let me write the UPDATE first.
I plan to to this:
Where the "select"-statement is adjusted for the user-needs, I would adjust the UPDATE as well.
May I just copy the suggested SQL-code from the editor for the appropriate table? Or will I have to add the user choice with the where-clause as well?
And is it correct, only to change the ModifySQLß?
But the chance always exists that you catch multiple records.
OMG!
This is the worst case, that my data become wrong.
Will the definition of a primary key help against this?
I am not good ad database connections and so everything is in a DB-Modul, where there is a transaction1, which is allowed to autocommit. So I do nothing with databases and transactions any more. The datasensitive component just points as the db-modul and I do not care any more.
That's also they way you connect tables together.
TABLE CLIENT
ID BIGINT
TABLE ORDERS
ID BIGINT
ORDERNR BIGINT
CLIENT_ID (foreign key linking to CLIENT.ID)
Not sure, if this is done and replaces your text above. I do not understand it really.
To make a primary key, I usually go to FlameRobin and click cluelessly around for half an hour until there is one by good luck.
I don't know TIBDynamicGrid
"Our" Tony wrote it!
Give it a try.
you also need to set the ModifySQL, InsertSQL and DeleteSQL.
ModifySQL and Update are the same?
Not sure, if I will provide an insert and a delete as well.
Do you think, it is the better performance to change all of these or to have several IBDataSets which I let point at their table at designtime?
So one idea is
table1 with ibDataSet1 / table2 with ibDataset2 / table 3 with ibDataset 3
the second idea is
IBdataset1 with Queryies for table 1 / IBdataset1 with Queryies for table 2 / IBdataset1 with Queryies for table 3
Are those records not used anywhere else in your program, or linked to other tables?
Everything was fine by good luck and there shall not be any problem.
I am long enough in programming, that I know, how quickly problems occur, that "shall not" occur.
I will go ahead and click half an hour in FlameRobin to make one field primary key.