Database name from DBGrid lazarus / 16-Databases ---------------------------------------------------------------------- daveinhull · 2018-12-30 15:24 Hi, Is it possible to get the Database name from the DBGrid. I can get the DataSource and from that the DataSet, but then can't get any further to the Database. Thanks Dave ---------------------------------------------------------------------- balazsszekely · 2018-12-30 15:39 Assuming that the dataset is a TSQLQuery and DBGrid1 is the name of the grid: 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 TSQLQuery(DBGrid1.DataSource.DataSet).DataBase.DatabaseNameSimilar typecast is also possible for other type of datasets too. ---------------------------------------------------------------------- daveinhull · 2018-12-30 15:53 Excellent GetMem, many thanks Think I've still got a lot to learn! ---------------------------------------------------------------------- mangakissa · 2018-12-31 07:50 Why do you want to know the databasename with your grid? ---------------------------------------------------------------------- daveinhull · 2018-12-31 16:31 Hi mangakissa, Actually I need the ODBCConnection. What I'm doing is trying to write a procedure that puts filter buttons on each column of a DBGrid (a bit like in MS Excel/Access). I just want to pass the DBGrid as a parameter. I'm trying to get small buttons in the column title row, but having difficulties, see http://forum.lazarus.freepascal.org/index.php/topic,43711.0.html. When the button is pressed it opens a Form with a few buttons (like set all, clear all, quite etc.) and a DBGrid with a Bookmarklist in Column 1 and the field where the button was pressed in the second column. I'm also having problems with Bookmarklist see http://forum.lazarus.freepascal.org/index.php/topic,43713.0.html. However, I've done a work around at the moment which works. The DBGrid in the opened window is fed with a SQLQuery which is pretty simple SELECT ColumnName FROM Table GROUP BY ColumnName. However, the SQL needs the DB Connection that the main DBGrid is fed from. I'm also trying to extract the Table name from the original DBGrid dataset, but this could be quite a task unless I keep the oringinal DBGrid query simple, SELECT * FROM Table; then I can get it from the SQL string in the DataSet in the passed DBGrid. I'm probably making a mountain out of a molehill, but I am learning quite a bit as I'm doing this so enjoying it. I did ask if there was already some control which provided MS Excel/Access filter drop downs but haven't got any replies. Dave ---------------------------------------------------------------------- mangakissa · 2018-12-31 17:03 Why not feeding the columns in multiple stringlists (one by each column) and set the uniique option to true. Then you need one query for all the things you need whitout a connection to a database