如何获得DBExpress TSqlConnection实际连接到的数据库的名称? [英] How can I get the name of the database a DBExpress TSqlConnection is actually connected to?

查看:99
本文介绍了如何获得DBExpress TSqlConnection实际连接到的数据库的名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在测试一个相当老的Delphi 6应用程序,并且想显示TSqlConnection实际连接到的数据库名称,因此我可以快速查看是否连接到测试或生产数据库。



在sqlconnections.ini中,应用程序具有一个名为 Vienna的连接到如下定义的Firebird数据库:
Database = 192.168.1.15:ProductionDB(这是别名)
,为了测试目的,我将其替换为
Database = 192.168.1.15:TestDB。



但是我已经看到仅访问TSqlConnection的参数-List,数据库的值不起作用。此值始终设置为与设计模式下相同。



如何找出TSqlConnection实际连接到哪个数据库(在我的情况下为哪个Firebird别名) ?

解决方案

监视表已引入FB 2.1.x:-)



所以尝试

 从MON $ DATABASE 
中选择MON $ DATABASE_NAME pre>

或尝试

 从MON $ ATTACHMENTS中选择MON $ ATTACHMENT_NAME 
,其中MON $ ATTACHMENT_ID = CURRENT_CONNECTION

查看信息




I'm testing a quite old Delphi 6 application and would like to display the database name the TSqlConnection is actually connected to, so I can see quickly if I'm connected to the test or production database.

In sqlconnections.ini, the app has a connection named 'Vienna' to a Firebird database defined like this: Database=192.168.1.15:ProductionDB (it's an alias) and I've replaced that for testing purposes with Database=192.168.1.15:TestDB.

But I've seen that just accessing the TSqlConnection's Params-List and there the value of 'Database' does not work. This value is always set the same as it is in design mode.

How can I find out which database (which Firebird alias in my case) the TSqlConnection is actually connected to?

解决方案

monitoring tables were introduced into FB 2.1.x :-)

So try

 select MON$DATABASE_NAME from MON$DATABASE

Or try

 select MON$ATTACHMENT_NAME from MON$ATTACHMENTS
    where MON$ATTACHMENT_ID = CURRENT_CONNECTION

See info at

这篇关于如何获得DBExpress TSqlConnection实际连接到的数据库的名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆