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

Article translations Article translations
Article ID: 914174 - View products that this article applies to.
Expand all | Collapse all

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:

Collapse this imageExpand this image
Download
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:
  1. Extract the Ssceoledb.h file from the Ssceoledb.exe file.
  2. Copy the Ssceoledb.h file to a folder where Visual Studio 2005 can find the file and include the file in the application.
  3. Extract the NorthwindOleDb.zip package from the following folder:
    SQL2005Install:\Program Files\Microsoft SQL Server 2005 Mobile Edition\Samples\NorthwindOleDb
    Notes
    • In this folder, SQL2005Install 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.
  4. Open the C:\northwindoledb folder, and then double-click the Northwindoledb.sln file. The NorthwindOleDb sample application opens in Visual Studio 2005.
  5. In Solution Explorer, right-click Header Files, point to Add, and then click Existing Item.
  6. 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.
  7. In all the source files in this application, delete the following line of code.
    #include <oledb.h>
  8. In all the source files in this application, locate the following line of code.
    #include <ssceoledb30.h>
    Replace this line of code with the following line of code.
    #include <MyPath\ssceoledb.h>
    Make this replacement because the Ssceoledb30.h file is used in Microsoft SQL Server 2005 Compact Edition (SQL Server Compact Edition) OLE DB applications.

    Note In this line of code, MyPath is a placeholder for the folder where you copied the Ssceoledb.h file. Alternatively, you can add the MyPath folder to the include folder in Visual Studio 2005.
  9. If the Oledb.lib file is in the link library, delete the Oledb.lib file.
  10. 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.
  11. In all the source files in this application, change the CLSID_SQLSERVERCE_3_0 class identifier to the CLSID_SQLSERVERCE_2_0 class identifier.
  12. In Solution Explorer, right-click Northwindoledb, and then click Properties.
  13. In the left pane, expand Configuration Properties, expand Linker, and then click Input.
  14. In the right pane, click Additional Dependencies, and then click the ellipsis button.
  15. 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:
    VSInstall:\Program Files\Microsoft Visual Studio 8\SmartDevices\SDK\PocketPC2003\Lib\armv4
    Note In this folder, VSInstall is a placeholder for the drive where you install Visual Studio 2005.
  16. Make sure that you call the following function before you call the OLE DB methods.
    CoInitializeEx(NULL, COINIT_MULTITHREADED)
  17. Build the application.
  18. Deploy the application to the device.
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:
  1. Copy the NetcfV1.platform.processor.cab file to the device from the following directory:
    VSInstall:\Program Files\Microsoft Visual Studio 8\SmartDevices\SDK\CompactFramework\2.0\v1.0\WindowsCE\platform\processor\
    Note In these steps, platform is a placeholder for the operating system for the Windows Mobile 2003-based device or for the Windows Mobile 5.0-based device. Additionally, processor is a placeholder for the microprocessor for the Windows Mobile 2003-based device or for the Windows Mobile 5.0-based device.
  2. On the device, click the NetcfV1.platform.processor.cab file to install the Microsoft .NET Compact Framework.
  3. Copy the Sqlce20.dev.ppc.platform.processor.cab file and the Sqlce20.ppc.platform.processor.cab file to the device from the following directory:
    VSInstall:\Program Files\Microsoft Visual Studio 8\SmartDevices\SDK\SQL Server\Mobile\v2.0\platform\processor\
  4. On the device, click the Sqlce20.dev.ppc.platform.processor.cab file and the Sqlce20.ppc.platform.processor.cab file to install SQL Server CE.
You can also add OLE DB error checking in the application. For more information about the OLE DB errors, see the "Using OLE DB Error Objects" topic in SQL Server CE Books Online.

REFERENCES

For more information about how to build an OLE DB application for SQL Server CE on Microsoft Windows .NET devices, click the following article number to view the article in the Microsoft Knowledge Base:
825393 Building OLE DB applications for SQL Server CE 1.1, SQL Server CE 2.0, and Windows CE .NET

Properties

Article ID: 914174 - Last Review: December 8, 2006 - Revision: 2.3
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
Keywords: 
kbexpertiseadvanced kbvs2005std kbvs2005pro kbinfo KB914174

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com