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

原文地址:http://support.microsoft.com/kb/914174/en-us/

中文地址:http://support.microsoft.com/kb/914174/zh-cn

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.

(http://download.microsoft.com/download/d/0/3/d0337fad-0a9d-4c87-9fe2-c5a2916c7b80/ssceoledb.exe)

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 (http://support.microsoft.com/kb/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.

3Extract the NorthwindOleDb.zip package from the following folder:

SQL2005Install:/Program Files/Microsoft SQL Server 2005 Mobile Edition/Samples/

NorthwindOleDb

Notes

In this folder,SQL2005Installis 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 (http://support.microsoft.com/kb/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-clickHeader Files, point to Add, and then clickExisting Item.

6 To add the Ssceoledb.h file to the Header Filelist, 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,MyPathis a placeholder for the folder where you copied the Ssceoledb.h file. Alternatively, you can add theMyPathfolder 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,VSInstallis 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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值