Forum > Databases

[SOLVED] Dubble records

(1/2) > >>

madref:
I have a database and when I open the form the DBGrid is filled correctly.


But when I am opening the form for a second time I get the records twice and if I open the form for a third time...you guess it's 3 times the same records...


What am I doing wrong .

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm_Straffen_Keuze.FormShow(Sender: TObject);var cSQL: string;begin  // Tijdelijke tabel verwijderen als deze bestaat.  Form_Lint.Connect_RefereeDB.ExecuteDirect('DROP TABLE IF EXISTS tbl_Temp_Spelers');  Form_Lint.Trans_RefereeDB.Commit;  cSQL := '';  cSQL := 'CREATE TABLE tbl_Temp_Spelers (' +          'P_ID WORD NOT NULL PRIMARY KEY ASC, ' +          'P_Team VARCHAR(100), ' +          'P_Team_ID WORD, ' +          'P_Naam VARCHAR(100), ' +          'P_BondsNummer VARCHAR(10), ' +          'P_Penalty_Naam VARCHAR(10), ' +          'P_Min WORD' +          ')';  Form_Lint.Connect_RefereeDB.ExecuteDirect(cSQL);  Form_Lint.Trans_RefereeDB.Commit;//  Form_Lint.Connect_RefereeDB.ExecuteDirect('TRUNCATE TABLE IF EXISTS tbl_Temp_Spelers');  Form_Lint.Connect_RefereeDB.ExecuteDirect('DELETE FROM tbl_Temp_Spelers');  Form_Lint.Trans_RefereeDB.Commit;    Bepaal_Penalties;  // this sets the records in the tableend;     // FormShow 

Zvoni:
I‘m not even going to pretend to understand, why you
Drop a table, you create it, then you delete from this empty table….

As to your question: what‘s the recordcount (expected and after you pull the records)?
And what‘s the SELECT-query look like?
And do you clear the DBGrid resp. Query-Object when loading/showing the form?
Sounds like some cached Data

tt:

--- Quote from: madref on December 04, 2022, 12:34:27 pm ---I have a database and when I open the form the DBGrid is filled correctly.


But when I am opening the form for a second time I get the records twice and if I open the form for a third time...you guess it's 3 times the same records...


What am I doing wrong .

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm_Straffen_Keuze.FormShow(Sender: TObject);var cSQL: string;begin  // Tijdelijke tabel verwijderen als deze bestaat.  Form_Lint.Connect_RefereeDB.ExecuteDirect('DROP TABLE IF EXISTS tbl_Temp_Spelers');  Form_Lint.Trans_RefereeDB.Commit;  cSQL := '';  cSQL := 'CREATE TABLE tbl_Temp_Spelers (' +          'P_ID WORD NOT NULL PRIMARY KEY ASC, ' +          'P_Team VARCHAR(100), ' +          'P_Team_ID WORD, ' +          'P_Naam VARCHAR(100), ' +          'P_BondsNummer VARCHAR(10), ' +          'P_Penalty_Naam VARCHAR(10), ' +          'P_Min WORD' +          ')';  Form_Lint.Connect_RefereeDB.ExecuteDirect(cSQL);  Form_Lint.Trans_RefereeDB.Commit;//  Form_Lint.Connect_RefereeDB.ExecuteDirect('TRUNCATE TABLE IF EXISTS tbl_Temp_Spelers');  Form_Lint.Connect_RefereeDB.ExecuteDirect('DELETE FROM tbl_Temp_Spelers');  Form_Lint.Trans_RefereeDB.Commit;    Bepaal_Penalties;  // this sets the records in the tableend;     // FormShow 
--- End quote ---

I should post all the code in order to understand all the operations done on the table and/or on the graphical compenent.

When you posted shows only

1. drop a table if exists
2. recreate the same table
3. delete all records from the table jsut created (there is no record so this operation does nothing, unless betwee line 18 and 20 someone else writes data in the table)

madref:
i am dropping the table because it's a temporary table and I want to keep my database as small as possible.
The delete was a failed attemp to clear the table.


But the problem keeps coming back.


And yes the DBGrid and the Query is cleared.
The Query is just

--- Code: SQL  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---SELECT * FROM tbl_Temp_Spelers

How do you mean cached data when everything should be cleared of data


Recordcount is the first time 3 then 6 (2nd time) and 9 the third time.

tt:

--- Quote from: madref on December 04, 2022, 08:37:56 pm ---i am dropping the table because it's a temporary table and I want to keep my database as small as possible.
The delete was a failed attemp to clear the table.


But the problem keeps coming back.


And yes the DBGrid and the Query is cleared.
The Query is just

--- Code: SQL  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---SELECT * FROM tbl_Temp_Spelers

How do you mean cached data when everything should be cleared of data


Recordcount is the first time 3 then 6 (2nd time) and 9 the third time.

--- End quote ---

Relationship between Form_Lint.Connect_RefereeDB wher you do the operations and Form_Lint.Trans_RefereeDB where you do the commits?

Navigation

[0] Message Index

[#] Next page

Go to full version