在 Inno-setup 项目中查询 SQL Server

发布于 2024-09-07 08:19:02 字数 239 浏览 3 评论 0原文

我正在使用 Inno-setup 创建一个设置。
在设置过程中,必须创建 SQL Server 数据库。我想让用户能够选择现有的 SQL Server 实例(如果存在),必须在其中创建数据库。
因此,我在设置中想要做的是查询网络(和本地计算机)中的 SQL Server 实例。

此外,当用户选择一个实例时,我想验证是否存在该实例上具有特定名称的数据库。

有人知道我该怎么做吗?或者也许有人可以给我一些好的方向指示?

I'm creating a setup using Inno-setup.
During the setup process, a SQL Server database has to be created. I want to give the user the ability to select an existing SQL Server instance (if one exists), where the database has to be created.
So, what I want to do in the setup, is to query the network (and the local machine) for SQL Server instances.

Furthermore, when the user has selected an instance, I want to verify if there exists a database on that instance which has a specific name.

Anybody who knows how I can do this ? Or maybe someone could give me some pointers in the good direction?

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

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

发布评论

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

评论(2

你又不是我 2024-09-14 08:19:02

Inno Setup 支持调用外部 DLL 函数,因此您应该编写一个合适的辅助 DLL。托管 .net DLL 只能通过 COM 接口使用,否则您需要非托管 DLL。

有效的调用约定为:“stdcall”(默认)、“cdecl”、“pascal”和“register”。

Inno Setup supports the call of external DLL functions, so you should write a suitable helper DLL. Managed .net DLLs can only be used via a COM interface, otherwise you need an unmanaged DLL.

Valid calling conventions are: 'stdcall' (the default), 'cdecl', 'pascal' and 'register'.

余罪 2024-09-14 08:19:02

尝试以下本机 .Net 库调用:

using System.Data.Sql;

var instance = SqlDataSourceEnumerator.Instance;
DataTable dataTable = instance.GetDataSources();

生成的数据表包含以下列:

ServerName

服务器的名称。

InstanceName

服务器实例的名称。如果服务器作为默认实例运行,则为空。

IsClustered

指示服务器是否属于集群的一部分。

版本

服务器的版本(对于 SQL Server 2000 为 8.00.x,对于 SQL Server 2005 为 9.00.x)。

Try the following native .Net library call:

using System.Data.Sql;

var instance = SqlDataSourceEnumerator.Instance;
DataTable dataTable = instance.GetDataSources();

The resultant datatable contains the following columns:

ServerName

Name of the server.

InstanceName

Name of the server instance. Blank if the server is running as the default instance.

IsClustered

Indicates whether the server is part of a cluster.

Version

Version of the server (8.00.x for SQL Server 2000, and 9.00.x for SQL Server 2005).

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