使用 ODBC 从位于 Program Files 文件夹中的数据库读取 [英] Reading from a database located in the Program Files folder using ODBC

查看:30
本文介绍了使用 ODBC 从位于 Program Files 文件夹中的数据库读取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个应用程序将其数据库文件存储在 Program Files 目录的子文件夹中.这些文件在 Vista 和 Windows 7 中被重定向到 VirtualStore.我们使用 Microsoft DataReports (VB6) 表示来自数据库的数据.到目前为止一切顺利.

但是我们现在想使用 Crystal Reports XI 来表示来自数据库的数据.我们的想法是不要将这些数据从我们的程序传递给 CR,而是让 CR 通过 ODBC 使用系统 DSN 从数据库中检索它.通过这种方式,我们希望为我们的用户提供更多的灵活性来设计他们自己的报告.不过,我们想要确保的是,当用户安装我们的程序或程序调用 Crystal Report 时,这些系统 DSN 配置正确.

例如,是否有一种聪明的方法可以使用系统变量来执行此操作,而不必编写检查操作系统版本、是否在操作系统上启用 UAC、是否已解除对 Program Files 文件夹的写入限制等的例程然后调整系统 DSN 以指向 C:Program FilesOurAppData 文件夹或 C:UsersUserAppDataVirtualStoreProgram FilesOurAppData 文件夹?

也欢迎提出完全不同的方法的建议!

We have an application that stores its database files in a subfolder of the Program Files directory. These files are redirected to the VirtualStore in Vista and Windows 7. We represent data from the database using Microsoft DataReports (VB6). So far so good.

But we now want to use Crystal Reports XI to represent data from the database. Our idea is to NOT pass this data to CR from our program, but to have CR retreive it from the database using a a system DSN through ODBC. In this way we hope to present our users with more flexibility in designing their own reports. What we do want to ensure though is that these system DSNs are configured correctly when the user installs our program or when the program calls the Crystal Report.

Is there a smart way to do this using System variables for instance, instead of having to write a routine that checks for OS-version, whether UAC is enabled on the OS, whether the write restrictions on the Program Files folder have been lifted, etc and then adapts he System DSN to point to either the C:Program FilesOurAppData folder, or the C:UsersUserAppDataVirtualStoreProgram FilesOurAppData folder?

Suggestions for an entirely different approach are welcome too!

推荐答案

这是Access数据库吗?你没有指定.

Is this an Access database? You haven't specified.

对于 Access 数据库,安装时无需将 DSN 指向特定数据库.您可以在运行时修改连接字符串以指向不同的数据库(详细信息).比如

For an Access database, you don't need to point your DSN to a specific database when you install it. You can modify the connection string to point to different databases at runtime (details). For instance

Driver={Microsoft Access Driver (*.mdb)};Dbq=C:mydatabase.mdb;Uid=Admin;Pwd=;

您能否在运行时简单地读取安装路径(在 VB6 中为 App.Path),然后向 Crystal Reports 发送不同的连接字符串?

Can you simply read the installation path at runtime (in VB6 it is App.Path) and then send a different connection string to Crystal Reports?

这篇关于使用 ODBC 从位于 Program Files 文件夹中的数据库读取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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