Forum > Databases

Something wrong datasource recno

(1/1)

eldonfsr:
I have a table and i wanna to know what is the position suppos must be like that

RegAct := SQLQMovsParts.DataSource.DataSet.RecNo;
but give me 0 never the position of recno
what i doing wrong.

GAN:
Use your query not the dataset, because: http://lazarus-ccr.sourceforge.net/docs/fcl/db/tdataset.recno.html


--- 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";}};} ---RegAct := SQLQMovsParts.RecNo

kapibara:
Like GAN said. TDataSource.Dataset is implemented as a TDataSet. Your TSQLQuery is assigned to it, but you would need a cast to access the RecNo property since it is not implemented in TDataSet:


--- 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";}};} ---(DataSource1.DataSet as TSQLQuery).RecNo;

LacaK:
GetRecNo and SetRecNo are virtual in TDataSet.
so they can be and are overriden in TDataSet descendants, so there is no need to cast TDataSource.TDataSet

Why you get always 0 for RecNo may depend on situation where you are trying to read RecNo ?
(for example if you are inserting new record then RecNo of this new record is = 0)

eldonfsr:
ok thanks

Navigation

[0] Message Index

Go to full version