Dbgrid.DataSource.DataSet function lazarus / 16-Databases ---------------------------------------------------------------------- exdatis · 2012-06-02 10:35 Why expression:   if DBGrid.DataSource.DataSet.IsEmpty then      Showmessage('Empty set');//example does not work, actually makes exception? Thanks. p.s. Is expression: if not (DBGrid.DataSource.DataSet.Fields[index_of_field].Value = NULL) then   something; is better way? CT2.5, SQLdb, Firebird2.5, xubuntu(32 bit). ---------------------------------------------------------------------- otorres · 2012-06-02 16:27 Code: [Select]DBGrid.DataSource.DataSet.IsEmptyThis is a function of the class that no works because the DataSet no have set's of data internally, but if you need know if the DataSet have record use: Code: [Select]IF DBGrid.Datasource.DataSet.RecordCount <> 0 THEN //HAVE DATA Regards. ---------------------------------------------------------------------- Leledumbo · 2012-06-02 17:38 Quotedoes not work, actually makes exception?My guess: the dataset property is nil. ---------------------------------------------------------------------- exdatis · 2012-06-02 18:01 No, DBGrid have a DataSource, and a DataSource have a DataSet. Because I use the same SQLQuery when I need a simple select query, I always explicitly give properties(DataSet, DataSource, DisplayLabel, DisplayFormat etc.).   I tried   if DBGrid.DataSource.DataSet.Active then but unsuccessfully. Thanks Leledumbo! Regards! ---------------------------------------------------------------------- exdatis · 2012-06-02 18:04 Thank you, otorres! I'll try, for a minute! ---------------------------------------------------------------------- exdatis · 2012-06-02 18:19 Ohhhhh, I'm so stupid!  Leledumbo was right! I forget, when I stop to use the query, I set DataSet to nil. When DataSet is opened he has properly DataSet.    My simulation was with closed query, where I want to stop the user... Thanks guys!