Visual artefact in TDBGrid lazarus / 16-Databases ---------------------------------------------------------------------- LemonParty · 2024-02-20 19:03 I have a DBGrid, when I open SQLQuery in it I see dublicated records. Lazarus version 2.2.6. Is this a bug? ---------------------------------------------------------------------- dseligo · 2024-02-20 22:26 Probably you did something wrong in your query. ---------------------------------------------------------------------- vfclists · 2024-02-21 09:10 Quote from: LemonParty on February 20, 2024, 08:03:58 pmI have a DBGrid, when I open SQLQuery in it I see dublicated records. Lazarus version 2.2.6. Is this a bug? Questions like this are generally useless without code. Do you get the same duplication when you run the same query using some other utility? Is it a DISTINCT query? ---------------------------------------------------------------------- rvk · 2024-02-21 09:18 Quote from: LemonParty on February 20, 2024, 08:03:58 pmI have a DBGrid, when I open SQLQuery in it I see dublicated records. Lazarus version 2.2.6. Is this a bug? Those are just duplicate records in your database. You can even see that some of those #5 records have different values (the first 2). So after that, you probably just added duplicate records to your database. BTW. This also means you don't have constraints build in your database to prevent duplicates (which is very BAD    ). ---------------------------------------------------------------------- wp · 2024-02-21 09:25 And what is the # column? An ID? Or just a counter? In any way, something is wrong here, too. This reminds me of some bug of the grid which repeated records at the end. Was it related to filtering? Cannot remember any details... It would be very helpful if you could set up a small test project to demonstrate the issue ---------------------------------------------------------------------- rvk · 2024-02-21 09:40 First make sure that there aren't duplicated records in your database. You can do that with your favorite databasemanager. ---------------------------------------------------------------------- Zvoni · 2024-02-21 10:18 Quote from: dseligo on February 20, 2024, 11:26:57 pmProbably you did something wrong in your query. Agreed. Show the Table-structure and the SELECT-Query and this thread is again proof positive, why i don't like DB-bound controls.... ---------------------------------------------------------------------- LemonParty · 2024-02-22 14:39 Structure: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i 'CREATE TABLE CURVE('+'[Number] INTEGER NOT NULL,'+'CurveNumber INTEGER NOT NULL,'+'LineNumber INTEGER NOT NULL,'+'Absorbance FLOAT,'+'Absorbance2 FLOAT,'+'Absorbance3 FLOAT,'+'Absorbance4 FLOAT,'+'Absorbance5 FLOAT,'+'Absorbance6 FLOAT,'+'Absorbance7 FLOAT,'+'Moisture FLOAT,'+'CONSTRAINT PK_CURVE PRIMARY KEY ([Number],CurveNumber,LineNumber))'Query: SELECT * FROM Curve Database Access, ODBC driver. This is not dublicates in database, when I scroll the table dublicates disappear and replaced by real records. # column is just a counter. ---------------------------------------------------------------------- Zvoni · 2024-02-22 15:06 Quote from: LemonParty on February 22, 2024, 03:39:50 pmDatabase Access, ODBC driver. And i'm out and running for the hills..... ---------------------------------------------------------------------- wp · 2024-02-22 15:37 I am attaching a small demo based on your CREATE TABLE. It runs on 32bit and 64bit Windows and does not show any duplicate records in the DBGrid. Please modify it such that the duplicate records appear. ---------------------------------------------------------------------- korba812 · 2024-02-22 15:51 Quote from: LemonParty on February 22, 2024, 03:39:50 pmDatabase Access, ODBC driver. This is not dublicates in database, when I scroll the table dublicates disappear and replaced by real records. # column is just a counter. Looks like improper buffer management in TSQLQuery/SQLdb? Maybe you have the "UniDirectional" property checked in your TSQLQuery? (edit: probably not because you wouldn't be able to scroll to the top of the DBGrid content) ---------------------------------------------------------------------- LemonParty · 2024-02-22 16:28 wp, here I reproduced. I built 32-bit application. ---------------------------------------------------------------------- wp · 2024-02-22 22:43 I see. Seems to be that the duplicate records are caused by the calculated fields. When I exit qCurveCalcFields immediately after the "begin", or when I unhook the OnCalcFields handler altogether, the fields are unique again (this is most easily seen when one of the "*Number" fields is added to the query). It would be interesting to investigate whether this issue is due to Access/ODBC or due to a bug in the field calculation. Both are not heavily used features in this community... I think there was a bug report about calculated fields sometimes, but I am not sure. I ran the test program also under FPC/main, and the issue remains - this means that this bug has not yet been fixed. I would recommend to do the calculation within the SELECT SQL, e.g. Code: [Select]  qCurve.SQL.Text := 'SELECT Moisture, Moisture*Moisture AS MoistureSquare, Absorbance, (1.0 - Absorbance) AS Residual FROM CURVE'; ---------------------------------------------------------------------- korba812 · 2024-02-22 22:56 I noticed that in TSQLQuery you have fewer data fields than those selected in query (SQL select...). Does the problem still occur if you add all data fields or modify query to only retrieve fields corresponding to defined data fields in SQLQuery?