views:

56

answers:

2

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?

A: 

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).

Brian Scott
Can I call this from Inno-setup (which uses some object-pascal like language ? )
Frederik Gheysels
sorry, i misread. I thought you were looking for a .Net solution.
Brian Scott
You can use any kind of Win32 DLL.
splash
@splash: Does that include managed .net dlls? If so then my original answer should work fine and bring back a list of all available SQL servers on the network.
Brian Scott
Managed .net DLLs can only be used via a COM interface.
splash
A: 

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'.

splash