After your application is fully migrated to client/server, a few outstanding issues still exist, such as how you can distribute the application. The largest challenge comes into play when you need to send it to someone geographically removed from you or when you determine that you have a salable commercial application. Some things to consider are creating the SQL Server database, setting up an ODBC data source, and loading any existing data into the SQL Server tables.
To implement a client/server solution, it's necessary to set up the ODBC data source. It's not a difficult task to complete manually, but if you're developing applications for the commercial market or large numbers of corporate users, you can consider including an automated way to accomplish this; your alternatives are to visit each desktop yourself and configure each PC individually, or teach your users how to install a data source themselves. Visiting every single desktop is generally impractical—especially in the case of a commercialized application—and your users might not be able to set up the ODBC data source. Therefore, creating your own custom installation program might be a good alternative.
You can use DLL functions to set up an ODBC data source. The ODBC Administrator itself is a DLL that contains a number of functions for installing drivers and adding, modifying, and removing data source definitions. The installation program uses these functions to install the ODBC components necessary to use the sample time and billing database.
Listing 24.3 shows the primary subroutine that runs the installation program, which is contained in the code module for frmODBCInstaller that's in Chap24.mdb on the CD-ROM. You can view this code yourself by opening the form's module in Design view. You can use this as the basis for your own installation program. Listing 24.3 installs the SQL Server ODBC driver and sets up a data source. It can optionally install ODBC Driver Manager and the Control Panel application. Figure 24.11 shows frmODBCInstaller in Form view.
Note
Although this installation program is included as an Access 2000 database, the code is compatible with Visual Basic versions 4.0 and later if you prefer to write your application with that tool.
SQL Server provides a great utility for re-creating SQL Server objects. By using Enterprise Manager, one of the administrative tools provided with SQL Server, you can select which objects you want to create, and SQL Server writes the scripts. This is especially useful for distributing your client/server application commercially, or for distributing to sites that don't have a resident SQL Server expert to set up the SQL Server device, set up the database, and then create all the tables with their necessary defaults, rules, and so forth.
Note
Enterprise Manager is not included with the Workstation version of SQL Server (the Microsoft Data Engine) that ships with Microsoft Office Developer.
To create SQL scripts, follow these steps:
1. |
Start SQL Enterprise Manager. This application exists on the Windows NT Server machine running your SQL Server, but must be added to a Windows NT or Windows 9x development workstation by installing the SQL Server Client Utilities from a SQL Server setup CD-ROM. |
2. |
Use Server Manager's tree view to select the database you want to create scripts for. |
3. |
From the Tools menu, choose Database Scripting. |
4. |
Select which objects you want to create scripts for and set any scripting options in the Generate SQL Scripts dialog. |
5. |
Click the OK button. |
Another alternative is using Automation to create your SQL Server database. A feature in SQL Server 6.0 and later is Distributed Management Objects (DMO). The SQL-DMO object model includes objects, properties, methods, and collections that you can use to write programs to administer multiple SQL Server databases distributed across your network. You can use Visual Basic for Applications or C++ to write programs that use SQL-DMO objects (from Access, create a reference in VBA to the Microsoft SQLDMO Object Library). Refer to the SQL Server Books Online for more information on DMO. SQL Server 7.0 has an additional tool set—Data Transformation Services (DTS)—that can be scripted or programmed for various database management tasks. Finally, you can use ADO to send data definition language (DDL) commands from your application to SQL Server to modify a database structure (see the Access help topic Microsoft ADO Extensions for DDL and Security (ADOX) Programmer's Reference for more information).
After your tables are created in SQL Server, you should have a plan for loading any existing data onto the server. This can be as simple as a series of Access queries or as complex as an interactive, flexible data-conversion program.
18.117.11.247