PenelopeSkye 1 Posted March 27, 2023 I created a test database and pointed the connection string to it, and I found 1 other place where the database name is mentioned after searching in all files. Unfortunately although some of the code works to insert into the database, not everything does, and I am thinking that there are other places indicating the database that I am not finding by using the search function. Does anyone know how to find other places where code is pointed to a database or do I need to search through every object? Thanks! Share this post Link to post
mvanrijnen 123 Posted March 27, 2023 we use agent ransack for searching things like this, found on: Agent Ransack – Mythicsoft then search on all *.pas, *.dfm, *.fmx files. But if you smart then you use a TDatamodule, where you put yout connection in/on, and in other units you point to that connection, (maybe nog the connection itself), but ask the datamodule for a new connection instance etc. Share this post Link to post
programmerdelphi2k 237 Posted March 27, 2023 (edited) if the "text desired" is in "text format (not coded, hex, binary, etc...) then, you can try use the "Search in Files" in Edit menu from Delphi... Text to find = << your text >> (not whole world...) Search in ALL FILES in PROJECT... file mask = (empty or *.* ) dir = << your project fodler >> is this? Edited March 27, 2023 by programmerdelphi2k Share this post Link to post
PeterBelow 238 Posted March 29, 2023 On 3/27/2023 at 7:51 PM, PenelopeSkye said: I created a test database and pointed the connection string to it, and I found 1 other place where the database name is mentioned after searching in all files. Unfortunately although some of the code works to insert into the database, not everything does, and I am thinking that there are other places indicating the database that I am not finding by using the search function. Does anyone know how to find other places where code is pointed to a database or do I need to search through every object? Thanks! Are you working on an older project written by someone else? Which database framework does it use, FireDAC, IBObjects, ADO (dbGo), BDE, some 3rd-party framework? In a properly designed DB app there should be only one place that uses the actual database name: the object handling the database connection/session . All other objects accessing the database should use this connection instance. A possible exception are apps that need to work with the same database from more than one thread, since DB sessions are usually bound to the thread that creates them. Share this post Link to post
DelphiUdIT 176 Posted March 29, 2023 (edited) You can use "grep" command line application (at command prompt). I use that to find reference of something in source directory of Rad Studio. I.e.: serching the word database in all PAS files in every subdirectories. You can repeat with *.DFM to search such reference in the object property. Quote grep -i -d "database" *.pas Edited March 29, 2023 by DelphiUdIT Share this post Link to post
programmerdelphi2k 237 Posted March 29, 2023 grep -dincl "Form1" *.* // find "Form1" in any file, counting occurrences, in sub-dirs, no case Share this post Link to post