Embedding Microsoft SQL Server in Your Application

Matt Domo
Microsoft Corporation

August 1997

Click to open or copy the sample files associated with this technical article.

Introduction

This paper provides a blueprint for embedding Microsoft® SQL Server™ administration features in an application. By automating and embedding system administration tasks, you can assume administration responsibilities. As a result, many tasks usually performed by a database or system administrator can be minimized or eliminated in the end user's application environment. There are six areas of administration that must be addressed to successfully deploy SQL Server in an unattended environment:

This paper covers each of these basic administrative tasks. It provides a background description and an example of how the task can be performed within the scope of the application system. Using the methodology defined in this paper, you can deploy SQL Server in an unattended environment.

Why Embed Microsoft SQL Server?

Microsoft SQL Server is a powerful and flexible relational database management system (RDBMS). SQL Server's features and capabilities allow it to be used in a wide variety of situations and end-user environments. Traditionally, a system or database administrator has been required to monitor and optimize SQL Server's performance in an end user's environment. However, because of time, planning, or resource constraints, finding a person to address these matters may be difficult. Therefore, embedding SQL Server administration functionality within your application offers several distinct advantages:

Development and Application Platforms

For clarity and ease of presentation, the reference development and application platforms are assumed to be Microsoft Visual C++®, Microsoft Visual Basic ®, Microsoft Windows NT®, and Microsoft Windows® 95. The function and DLL references throughout this document reflect this assumption. However, these techniques can also be applied to other compilers that create Microsoft Windows applications.

Sample Application and Code References

The following sample applications and code samples are referenced and included with this paper.

Setupini.exe

Setupini.exe is a sample Visual Basic application that performs an installation for a fictitious application called XYZ. The application performs an unattended installation of SQL Server and creates the application database and database objects. The program:

This application uses SQL Distributed Management Objects (SQL-DMO) 32-bit COM collections, objects, properties, and methods to perform these tasks.

Monitor.exe

Monitor.exe is a sample application that demonstrates how to configure SQL Server to automatically monitor database and transaction log space and to automatically take corrective action when either of these items exceeds a predefined space-used threshold. The application illustrates the following technologies:

Alert.exe

Alert.exe is a sample application that shows how to configure SQL Server to automatically monitor itself for high severity errors and to automatically notify someone that an issue needs attention. The application illustrates the following technologies: