Building an OLE DB Application (SQL Server Compact)

You can create native desktop and smart device applications within Visual Studio 2008 IDE by using Microsoft Visual C++. This topic provides the information that you must have to start to build an OLE DB Visual C++ application.

Creating a Project

To create a new application, you first create the project in Visual Studio 2008.

To create a new desktop project

  1. In Visual Studio 2008, on the File menu, point to New, and then select Project.

  2. In the Project Types list of the New Project dialog box, expand the Visual C++ programming language, and then select the type of project you want to create. For example, to create an ATL project, select ATL.

  3. Provide a name and location for your project, and then click OK. Visual Studio creates a new project.

To create a new smart device project

  1. In Visual Studio 2008, on the File menu, point to New, and then select Project.

  2. In the Project Types list of the New Project dialog box, expand the Visual C++ programming language, and then select Smart Device.

  3. In the Templates list, select the type of project you want to create. For example, to create an ATL project, select ATL Smart Device Project.

  4. Provide a name and location for your project, and then click OK.

    Visual Studio creates a new project.

Including the SQL Server Compact 3.5 OLE DB Provider

The next step in building an OLE DB-enabled application is to include the appropriate header files. In the main entry point for your application, add include statements for the SQL Server Compact 3.5 OLE DB provider and the SQL Server Compact 3.5 error file:

#include <sqlce_oledb.h>
#include <sqlce_err.h  >

Create an Instance of the OLE DB Provider

The final step in using OLE DB in your application is to create an instance of the provider. The following code demonstrates how to do this:

hr = CoCreateInstance(CLSID_SQLSERVERCE, 0, CLSCTX_INPROC_SERVER, IID_IDBProperties, (void**) &pIDBProperties);

See Also

Concepts

Native Programming How Tos (SQL Server Compact)

Other Resources

OLE DB Provider Reference (SQL Server Compact)

Help and Information

Getting Assistance (SQL Server Compact 3.5 Service Pack 1)