用户 DSN 和 系统DSN - 如何选择系统?

发布于 2024-07-13 11:28:14 字数 294 浏览 18 评论 0原文

设想: 我们的安装包用于添加用户 DSN。 由于终端服务器和 Citrix,我们对此进行了更改以安装系统 DSN。

问题在于,其中一些旧的用户 DSN 正在浮动,并且我们的应用程序会在系统之前自动选择用户,并且随着我们升级服务器软件,连接信息已发生变化。

我想我的问题是,如果存在重复项,是否有办法强制应用程序使用系统 DSN 而不是用户 DSN?

我们的应用程序是用 PowerBuilder 10.5 编写的,并使用 SQL Anywhere 10.0.1。

谢谢, 卡尔文

Scenario:
Our install package used to add User DSN. We changed this to install System DSNs due to Terminal Servers and Citrix.

The problem is that some of these old User DSNs are floating around, and our application automatically chooses the User before the System and the connection info has changed as we upgraded server software.

I guess my question is, is there a way to force the application to use the System DSN over the User DSN if duplicates exist?

Our application is written in PowerBuilder 10.5 and we use SQL Anywhere 10.0.1.

Thanks,
Calvin

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

堇年纸鸢 2024-07-20 11:28:14

有关用户 DSN 的信息存储在注册表中。 您是否考虑过简单地执行几次注册表读取,然后删除/重命名无效的 DSN,或者警告用户有关冲突并为用户提供修复问题的选项?

The information about user DSN(s) are stored in the registry. Have you considered simply doing a couple registry reads and then either deleting/renaming the invalid DSN, or warning the user about the conflict and giving the user the option to repair the issue?

一页 2024-07-20 11:28:14

请参阅 PowerBuilder 帮助中的RegistryValues()。 下面的内容并不完全是您想要的,但它确实显示了几个工作调用...

integer li_RC
string  ls_odbc_ini[]

li_RC = RegistryValues ( &
   "HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\ODBC Data Sources", &
    ls_odbc_ini )

IF li_RC <> 1 THEN
    MessageBox ( 'Error', &
        'RegistryValues failed in website.open' )
    RETURN
END IF

MessageBox ( 'A user DSN...', ls_odbc_ini[1] )

li_RC = RegistryValues ( &
   "HKEY_LOCAL_MACHINE\Software\ODBC\ODBC.INI\ODBC Data Sources", &
    ls_odbc_ini )

IF li_RC <> 1 THEN
    MessageBox ( 'Error', &
        'RegistryValues failed in website.open' )
    RETURN
END IF

MessageBox ( 'A system DSN...', ls_odbc_ini[1] )

另一个建议是从您想要的任何 DSN 中读取连接信息,然后使用“无 DSN”连接,以避免“选择”错误的 DSN”。

SQLCA.DBMS = 'ODB'

SQLCA.DBParm &
    = "ConnectString='Driver=SQL Anywhere 10;" &
    + "UID=dba;PWD=sql;DatabaseName=ruralfinds_local;EngineName=ruralfinds_local'," &
    + "ConnectOption='SQL_DRIVER_CONNECT,SQL_DRIVER_NOPROMPT'"

CONNECT USING SQLCA;

IF SQLCA.SQLCODE <> 0 THEN
    MessageBox ( 'Error', &
        'CONNECT failed in open:' &
        + '~r~nSQLCode = ' &
        + String ( SQLCA.SQLCode ) &
        + '~r~nSQLDBCode = ' &
        + String ( SQLCA.SQLDBCode ) &
        + '~r~n' &
        + SQLCA.SQLErrText )
    RETURN
END IF

布雷克

See RegistryValues() in the PowerBuilder Help. The following isn't exactly what you want but it does show a couple of working calls...

integer li_RC
string  ls_odbc_ini[]

li_RC = RegistryValues ( &
   "HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\ODBC Data Sources", &
    ls_odbc_ini )

IF li_RC <> 1 THEN
    MessageBox ( 'Error', &
        'RegistryValues failed in website.open' )
    RETURN
END IF

MessageBox ( 'A user DSN...', ls_odbc_ini[1] )

li_RC = RegistryValues ( &
   "HKEY_LOCAL_MACHINE\Software\ODBC\ODBC.INI\ODBC Data Sources", &
    ls_odbc_ini )

IF li_RC <> 1 THEN
    MessageBox ( 'Error', &
        'RegistryValues failed in website.open' )
    RETURN
END IF

MessageBox ( 'A system DSN...', ls_odbc_ini[1] )

Another suggestion is to read the connection information from whichever DSN you want, and then use a "DSN-less" connection, to avoid "picking the wrong DSN".

SQLCA.DBMS = 'ODB'

SQLCA.DBParm &
    = "ConnectString='Driver=SQL Anywhere 10;" &
    + "UID=dba;PWD=sql;DatabaseName=ruralfinds_local;EngineName=ruralfinds_local'," &
    + "ConnectOption='SQL_DRIVER_CONNECT,SQL_DRIVER_NOPROMPT'"

CONNECT USING SQLCA;

IF SQLCA.SQLCODE <> 0 THEN
    MessageBox ( 'Error', &
        'CONNECT failed in open:' &
        + '~r~nSQLCode = ' &
        + String ( SQLCA.SQLCode ) &
        + '~r~nSQLDBCode = ' &
        + String ( SQLCA.SQLDBCode ) &
        + '~r~n' &
        + SQLCA.SQLErrText )
    RETURN
END IF

Breck

半岛未凉 2024-07-20 11:28:14

由于您使用的是 SQL Anywhere,因此请查看它附带的 dbdsn 实用程序。 它将允许您列出、描述、创建和删除用户和系统 DSN。 例如,您可以使用它来查看用户 DSN 和系统 DSN 是否都存在并删除您不需要的 DSN。

Since you're using SQL Anywhere, take a look at the dbdsn utility that comes with it. It will allow you to list, describe, create, and delete both user and system DSNs. You can use it, for example, to see if user and system DSNs both exist and delete the one you don't want.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文