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



The information in this article applies to:

  • Microsoft SQL Server 6.5
  • Microsoft SQL Server 7.0
  • Microsoft Visual C++, 32-bit Enterprise Edition 6.0
  • Microsoft Visual C++, 32-bit Professional Edition 6.0
  • Microsoft Visual C++, 32-bit Learning Edition 6.0

This article was previously published under Q242027

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:
The Embedcgi.exe file contains the following files:

Embedtst.sqc2.2KB
Embedcgi.dsp4.4KB


Release Date: Feb. 03, 2000

For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.

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.
  2. In the Show Directories For box, click Include Files, and then add the Include folder for the SQL Server developer tools. For example:

    c:\mssql7\devtools\include

  3. Click Library Files in the Show Directories For box. Add the Lib folder for the SQL Server developer tools. For example:

    c:\mssql7\DevTools\lib

  4. Open the Embedcgi.dsp project in Visual C++.
  5. 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.
  6. 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:

    c:\mssql7\Binn\nsqlprep.exe $(inputname)

  7. 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 Script folder of the default Web server folder. For IIS, this folder is by default called "Scripts" and is located immediately under the Inetpub folder. For example:

    C:\Inetpub\Scripts

  2. Make sure that IIS has sufficient rights to run Scripts in this folder.

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?,,


Modification Type:MinorLast Reviewed:8/5/2004
Keywords:kbDatabase kbfile kbhowto KB242027