SAMPLE: Embedcgi.exe CGI Application Shows How to Use Embedded SQL

ID: Q242027


The information in this article applies to:
  • Microsoft SQL Server versions 6.5, 7.0
  • Microsoft Visual C++, 32-bit Editions, version 6.0


SUMMARY

The Embedcgi.exe sample shows you how to use embedded SQL in a Common Gateway Interface (CGI) application. This sample works with any CGI-compatible Web server; for example, Microsoft Internet Information Server (IIS).


MORE INFORMATION

The following file is available for download from the Microsoft Download Center. Click the file name below to download the file:

Embedcgi.exe
The Embedcgi.exe file contains the following files:

Embedtst.sqc 2.2KB
Embedcgi.dsp 4.4KB


Release Date: Feb. 03, 2000

For more information about how to download files from the Microsoft Download Center, please visit the Download Center at the following Web address
http://www.microsoft.com/downloads/search.asp
and then click How to use the Microsoft Download Center.

Compiling the Sample

  1. In the Microsoft Visual C++ Integrated Development Environment (IDE), on the Tools menu, click Options, and then click the Directories tab. Under the Show Directories For box, click Include Files and add the include directory for the SQL Server developer tools. For example:


  2. C:\mssql7\DevTools\Include
  3. Click Library Files in the Show Directories For box. Add the lib directory for the SQL Server developer tools. For example:


  4. C:\mssql7\DevTools\lib
  5. Open the Embedcgi.dsp project in Visual C++.


  6. Modify the Embedtst.sqc file so that the server name, database, user ID, and password variables match your computer configuration. The following two lines need to be changed:
    
    	char szSERVERNAME[]= "MYSERVER.pubs";
    	char szUID_PWD[]= "sa."; 
    Note that this sample uses the SQL Server sample Pubs database.


  7. On the Project menu, click Settings, and then click the Custom Build tab. Change the command to point to the correct location of the Nsqlprep.exe file on your computer. For example:


  8. C:\mssql7\Binn\nsqlprep.exe $(InputName)
  9. Compile your application.

    NOTE: The project contains a reference to a source file named Embedtst.c. This file is created by the Nsqlprep precompiler, so it does not need to exist prior to building the project.


Using the Sample

  1. Copy the compiled .exe file into the default Web server directory's SCRIPT subfolder. For IIS, this directory is by default called "SCRIPTS" and is located immediately under the INETPUB folder. For example:


  2. 
         C:\Inetpub\scripts 
  3. Make sure that IIS has sufficient rights to run scripts in this directory.


Calling Your CGI Application from a Web Browser

To call your CGI application, type the following in your browser's address edit box:
http://WEBSERVER/scripts/embedded.exe?,,

Additional query words:

Keywords : kbfile kbDatabase kbSQLServ kbVC kbGrpVCDB kbDSupport
Version : winnt:6.0,6.5,7.0
Platform : winnt
Issue type : kbhowto


Last Reviewed: February 3, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.