![]() |
Mixing of usersessions? - Printable Version +- Atozed Forums (https://www.atozed.com/forums) +-- Forum: Atozed Software Products (https://www.atozed.com/forums/forum-1.html) +--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html) +---- Forum: English (https://www.atozed.com/forums/forum-16.html) +----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html) +----- Thread: Mixing of usersessions? (/thread-1385.html) |
Mixing of usersessions? - etwoss - 11-16-2019 Hi I use a datamodule pool with my program. Each user can have a different db to look at. The usersession holds the path to that database, Now i adjusted the Lock and Unlock : Code: function LockDataModule: TDtmMain; And Code: procedure UnlockDataModule(ADataModule: TDtmMain); However, once in every 4-6 months we have a customer showing me data from another customers db! Which is ofcourse not what i want. After loggin out/in the users gets the correct database info. It's all about the line Code: Result.IBDatabase.DatabaseName := UserSession.DbPad; Which should work properly , if it choses someone else its usersession, this goes wrong. Any idea what could go wrong ??? Eric RE: Mixing of usersessions? - kudzu - 11-16-2019 1) If you are pooling you are recycling database connections and you certainly could be leaving open state between reuses. 2) Depending on your DB connectivity using the DB name may be invalid. Most connectivity components require explicit assigning by session instance when used in threads rather than by name. RE: Mixing of usersessions? - etwoss - 11-18-2019 Hi You say: 1) If you are pooling you are recycling database connections and you certainly could be leaving open state between reuses. Answer: All database actions are between a LockDataModule try..finally UnlockDataModule . So if you see my code this should really work fine. I always close the transactions/database before re-using 2) Depending on your DB connectivity using the DB name may be invalid. Most connectivity components require explicit assigning by session instance when used in threads rather than by name. Anwer: I use UserSession.DbPad, which contains the full file spec to my interbase database. I dont see this could go wrong. Strange is also that this happens only with the first form shown? This form shows a list of data, if i select a records it goes to a detail form , for which the technique is re-used and i get a error that the record was not found. The reason for this is that the detail uses a different database! This all happens just once in 3-4 months So what is the best approach now? Leave the pooling mechanisme? Eric RE: Mixing of usersessions? - DanBarclay - 11-18-2019 You might try logging database open/close vs session start to compare. Just a question: If you close/open the database when you attach to a pool module, is there any advantage of pooled vs having the data module in the usersession? Dan RE: Mixing of usersessions? - etwoss - 11-19-2019 Hi When i started pooling looked the right way to go, later i noticed that this is not really an advantage as you describe. I now disabled pooling, create the datamodule in my usersession, set the databasepath en it just works fine, Eric |