Encapsulation of native C + + Access SqlCe under Windows Mobile

Source: Internet
Author: User
Tags compact documentation microsoft sql server ole sql server express

Background

The development of Windows Mobile applications, many times the need for database access, storage and reading. However, Microsoft did not provide native C + + Ado.net under the package, so I encapsulated a sqlce access class.

Briefly

This article describes the implementation of the encapsulation class for Native C + + Access SqlCe under Windows Mobile and wince. Because Microsoft does not provide C + + like ado.net encapsulation, for native C + + Access SqlCe made a certain degree of difficulty, so the OLE DB Access SqlCe encapsulation to facilitate the use of SQL statements sqlce operation.

SqlCe Access Technology Overview Ado.net

The. NET Compact Framework is becoming the mainstream of Windows Mobile and wince development, Microsoft provides ado.net access SqlCe for cf.net, sqlce access encapsulated in System.Data.SqlServerCe, and other databases (SQL Server, Oracle) access is basically compatible, But DbProviderFactory is not supported. For example, the following code cannot be compiled because there is no sqlceproviderfactory class.

DbProviderFactory factory = SqlCeProviderFactory.Instance;

I have previously encapsulated a ado.net SqlCe access class that can refer to the use of SQL CE under the. NET Compact Framework (http://www.cnblogs.com/procoder/archive/2009/04/08/ 1431361.html) and the Unit test class that implements Sqlcehepler see unit tests under the. NET Compact Framework (http://www.cnblogs.com/procoder/archive/2009/04/ 08/1431724.html).

OLE DB

In the native World, OLE DB can be used to access sqlce. OLE DB is encapsulated under Sqlceoledb35.dll, and using OLE DB requires installing a CAB package as follows:

C:\Program Files\Microsoft SQL Server Compact Edition\v3.5\Devices\wce500\armv4i\sqlce.repl.ppc.wce5.armv4i.CAB

The above paths are different depending on the platform.

Note that the above Sqlceoledb35.dll only supports SqlCe 3.5, Microsoft's compatibility with different versions of SqlCe is not very good, you can refer to SQL Server Express and SQL Server Compact applications (http:// www.cnblogs.com/procoder/archive/2009/02/23/1396231.html) and the. NET campact framework under SQL CE compatibility issues (http:// www.cnblogs.com/procoder/archive/2009/04/15/1436275.html) Understand the history of SqlCe I compatibility issues.

The following article will focus on OLE DB.

Ado

In Windows Mobile and wince platforms, Microsoft does not support ADO. But there is a community implementation that can refer to a set of ADOCE classes (http://www.codeproject.com/KB/mobile/ado_ce_ca.aspx). I haven't tried it, so it's not good to comment.

Realize

The following describes how to implement access to SQLCE based on OLE DB.

Documentation and Samples

Microsoft provides online documentation for the Microsoft SQL Server Compact 3.5 Books Online and Samples (http://www.microsoft.com/downloads/details.aspx ? familyid=1ff0529a-eb1f-4044-b4b7-40b00710f7b7&displaylang=en) Download. The above link just contains the online documentation, does not provide an example program, so the name is a bit deceptive feelings. Although the documentation is available online, the quality of the document is not high, and some details are not spoken, such as invoking the ICommand::Execute entry parameters, which I can only try myself.

Although the link above does not provide samples, there is another way to get samples. In

C:\Program Files\Microsoft SQL Server 2005 Mobile Edition\Samples\NorthwindOleDb

You can get the sample code, provided that you have Microsoft SQL Server Mobile Edition installed. However, note that different SqlCe version implementation, this code should be combined with the above online book modification.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.