Microsoft KB Archive/914174

= How to build an OLE DB application for SQL Server CE in Visual Studio 2005 =

Article ID: 914174

Article Last Modified on 12/8/2006

-

APPLIES TO


 * Microsoft SQL Server 2000 Windows CE Edition 2.0
 * Microsoft Visual Studio 2005 Standard Edition
 * Microsoft Visual Studio 2005 Professional Edition
 * Microsoft Visual Studio 2005 Team System Developer Edition
 * Microsoft Visual Studio 2005 Team System Architect Edition

-





INTRODUCTION
This article describes how to build an OLE DB application for Microsoft SQL Server 2000 Windows CE Edition 2.0 (SQL Server CE) in Microsoft Visual Studio 2005. This article uses the NorthwindOleDb sample application that is installed with Visual Studio 2005 in an example.



MORE INFORMATION
To build an OLE DB application for SQL Server CE in Visual Studio 2005, you must include the new Ssceoledb.h file in the application. The new Ssceoledb.h file is an integration of the Oledb.h file, the Oledb.lib file, and the previous Ssceoledb.h file. To obtain the new Ssceoledb.h file, download the Ssceoledb.exe file from the Microsoft Download Center.

The following file is available for download from the Microsoft Download Center:

Download the Ssceoledb.exe package now.

For more 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 prevent any unauthorized changes to the file.

The following example shows how to build an OLE DB application for SQL Server CE in Visual Studio 2005. This example modifies the original version of the NorthwindOleDb sample application for SQL Server CE that is running on a Microsoft Windows Mobile-based device. To build the application, follow these steps:  Extract the Ssceoledb.h file from the Ssceoledb.exe file. Copy the Ssceoledb.h file to a folder where Visual Studio 2005 can find the file and include the file in the application. Extract the NorthwindOleDb.zip package from the following folder:



Notes  In this folder,  is a placeholder for the drive where you install Microsoft SQL Server 2005. If you cannot find the NorthwindOleDb.zip package, click the following article number to view the article in the Microsoft Knowledge Base:

909751 The NorthwindOleDb sample application is not available when you install SQL Server Mobile Edition from a SQL Server 2005 installation

 Step 4 assumes that you extract the NorthwindOleDb.zip package to drive C. You can select a different drive.</ul> </li> Open the C:\northwindoledb folder, and then double-click the Northwindoledb.sln file. The NorthwindOleDb sample application opens in Visual Studio 2005.</li> In Solution Explorer, right-click Header Files, point to Add, and then click Existing Item.</li> To add the Ssceoledb.h file to the Header File list, locate the folder where you copied the Ssceoledb.h file, and then double-click the Ssceoledb.h file.</li>  In all the source files in this application, delete the following line of code.  In all the source files in this application, locate the following line of code. Replace this line of code with the following line of code. Make this replacement because the Ssceoledb30.h file is used in Microsoft SQL Server 2005 Compact Edition (SQL Server Compact Edition) OLE DB applications.
 * 1) include <oledb.h> </li>
 * 1) include <ssceoledb30.h>
 * 1) include <MyPath\ssceoledb.h>

Note In this line of code,  is a placeholder for the folder where you copied the Ssceoledb.h file. Alternatively, you can add the  folder to the include folder in Visual Studio 2005. </li> If the Oledb.lib file is in the link library, delete the Oledb.lib file.</li> In all the source files in this application, delete the lines of code that contain the DBINITCONSTANTS symbol, the OLEDBVER symbol, and the INITGUID symbol.</li> In all the source files in this application, change the CLSID_SQLSERVERCE_3_0 class identifier to the CLSID_SQLSERVERCE_2_0 class identifier.</li> In Solution Explorer, right-click Northwindoledb, and then click Properties.</li> In the left pane, expand Configuration Properties, expand Linker, and then click Input.</li> In the right pane, click Additional Dependencies, and then click the ellipsis button.</li> Make sure that the Ole32.lib file, the Oleaut32.lib file, and the Uuid.lib file are listed in the Inherited Values box. If any one of these files is not listed, manually add the file in the box over the Inherited Values box. These files are in the following folder:



Note In this folder,  is a placeholder for the drive where you install Visual Studio 2005.</li>  Make sure that you call the following function before you call the OLE DB methods. CoInitializeEx(NULL, COINIT_MULTITHREADED) </li> Build the application.</li> Deploy the application to the device.</li></ol>

You may not be able to run the application on the device. This problem may occur when SQL Server CE is not installed on the device. To manually install SQL Server CE on the device, follow these steps: <ol> Copy the NetcfV1. . .cab file to the device from the following directory:



Note In these steps,  is a placeholder for the operating system for the Windows Mobile 2003-based device or for the Windows Mobile 5.0-based device. Additionally,  is a placeholder for the microprocessor for the Windows Mobile 2003-based device or for the Windows Mobile 5.0-based device.</li> <li>On the device, click the NetcfV1. . .cab file to install the Microsoft .NET Compact Framework.</li> <li>Copy the Sqlce20.dev.ppc. . .cab file and the Sqlce20.ppc. . .cab file to the device from the following directory:



</li> <li>On the device, click the Sqlce20.dev.ppc. . .cab file and the Sqlce20.ppc. . .cab file to install SQL Server CE.</li></ol>

You can also add OLE DB error checking in the application. For more information about the OLE DB errors, see the &quot;Using OLE DB Error Objects&quot; topic in SQL Server CE Books Online.

<div class="references_section">