Export (0) Print
Expand All

ODBC Samples

SQL Server 2000

The following samples have been developed for ODBC version 3.0 and later. The samples have all been developed with Microsoft® Visual C++® version 6.0, and some expose properties of the Microsoft Foundation Classes.

When you choose to install sample files, the ODBC 3.x samples are installed to the C:\Program Files\Microsoft SQL Server\80\Tools\DevTools\Samples\Odbc directory.

All samples include a project file (.dsw extension) created by Visual C++ 6.0. The project file can be opened in Visual C++ 6.0.

To open the project file in Visual C++ 6.0 and compile it:
  1. On the File menu, click Open Workspace.

  2. In the Files of type box, click Workspaces (*.dsw).

  3. Click the project file name.

  4. From the Tools menu, choose Options, and then click the Directories tab.

  5. From the Show directories for box, choose Include files and Library files, and ensure that the following directories are included and appear at the top of list:
    • Include files: C:\Program Files\Microsoft SQL Server\80\Tools\Devtools\Include

    • Library files: C:\Program Files\Microsoft SQL Server\80\Tools\Devtools\Lib
  6. From the Build menu, choose Rebuild All or Build *.exe.

When the project file is opened, Visual C++ generates appropriate supporting files.

The default build configuration for all samples is Win32® Debug, which will build the samples as 32-bit applications.

Note  To compile ODBC version 3.0 samples, you must obtain the ODBC 3.0 SDK available from Microsoft Press®, or the Microsoft Data Access SDK on the Microsoft Web site.

All versions of the Microsoft Foundation Classes database classes are ODBC version 2.x compliant. 2.x versions of the ODBC header files Sql.h, Sqlext.h, and Sqltypes.h ship in the Include directory of Microsoft Visual C++. You must ensure that 3.x versions of the header files are included in the build process and that 3.x versions of the libraries are used for linking.

Sample Data

Some of the samples rely on sample data provided in the C:\Program Files\Microsoft SQL Server\80\Tools\DevTools\Samples\Odbc\Data directory.

Three directories contain data for the samples. The BCP and LoadData samples each have a copy of the Microsoft Access-developed Northwind example data.

Directory Description
\Data\Northbcp Contains a copy of the Northwind data
\Data\North Contains a copy of the Northwind data
\Data\Trans Contains data used by the transaction processing and concurrency control sample

The sample data can be installed into any database. A Transact-SQL script, Createtb.sql, is installed into each sample data directory. The script creates the sample tables and stored procedures.

The scripts drop the tables they create so that they can be run multiple times as an example. Running the scripts in a database that contains data other than the supplied sample data can cause unintended results.

The sample data in \Data\Trans can be installed in any database. The sample data in the other two directories can be installed in any database except the Northwind sample database installed with SQL Server.

To load the sample data

  1. First make the ODBC samples and copy these files to a directory in your computer's path:
    C:\Program Files\Microsoft SQL Server\80\Tools\Devtools\Samples\ODBC\Loaddata\Release\Loaddata.exe
    C:\Program Files\Microsoft SQL Server\80\Tools\Devtools\Samples\ODBC\Bcp\Release\Bcpsamp.exe
    
  2. Open Control Panel/ODBC and define an ODBC data source with the database you want to hold the sample data as the default database.

  3. Open a command prompt window:
    cd C:\Program Files\Microsoft SQL Server\80\Tools\Devtools\Samples\ODBC\data\transloaddata
    

    When loaddata.exe starts, connect to the data source defined in step 2. Open the command file lddist.cmd using the CommandFile window, and then click GO. Click Close when the commands complete.

  4. In the command prompt window:
    cd C:\Program Files\Microsoft SQL Server\80\Tools\Devtools\Samples\ODBC\data\north loaddata
    

    When loaddata.exe starts, connect to the data source defined in step 2. Open the command file ldnorthw.cmd using the CommandFile window, and then click GO. Click Close when the commands complete.

  5. As an alternative to step 4 you can:
    cd C:\Program Files\Microsoft SQL Server\80\Tools\Devtools\Samples\ODBC\data\northbcp bcpsamp
    

    When BCPSamp.exe starts, connect to the data source defined in step 2. Open the command file bcpnorth.cmd using the CommandFile window, and then click GO. Click Close when the commands complete.

See Also

Samples

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft