在C++程序里使用ADOCE(英) |
|||
| 作者:Microsoft 来源:Microsoft 发布时间:2005-12-21 16:49:14 | |||
Using ADOCE from a C++ ApplicationPocket PC devices come preloaded with ADOCE (Active Data Objects for the Windows® CE operating system). This enables applications developers targeting the Pocket PC to take advantage of a powerful database language that is well established, well documented, and very robust. This article will show you how to access ADOCE from a C++ application.One of the (numerous) advantages the PocketPC developer has over their Palm counterparts is the ability to use SQL (structured query language) to access storage data. Developers have been using SQL for over a decade for desktop and workstation applications, and there are countless resources available both on SQL syntax and integrating SQL into various languages. With Active Data Objects (ADO), Microsoft has provided Windows developers with a common tool they can use from both C++ and Visual Basic applications (and any other language that uses COM objects) in a consistent manner. Unfortunately, using COM objects from C++ is not as simple as using them from Visual Basic, so Virtual Office Systems has created a free C++ class library encompassing the COM interface to the ADO objects.
GotchasADOCE 3.0 (the version that currently ships with the Pocket PC) has problems connecting to CDB files through the ADO Connection object. If a developer needs to access a CDB file, he or she needs to connect to the CDB file directly from the Recordset object, rather than reusing a Connection object for multiple Recordsets. Unfortunately, this means that each Recordset needs to establish its own connection, which is slower than using a single Connection object. This is supposed to be fixed in ADOCE 3.1.Languages SupportedEnglishQuerying Results from the Database with ADOTo retrieve the rows (also known as “records”) from a database table, ADO uses the SELECT command from SQL. The SELECT command provides a criteria of what to retrieve, known as the “WHERE clause” and an optional sort order. Once the SELECT command has been issued, the application can do something with each row returned. To issue a SELECT command and process the results:
Inserting Rows into the Database Through ADOTo add rows to a SQL database, each row must be “inserted” into the database. As long as the row doesn't violate the constraints of the table being added to (i.e. not providing a required column value), the new row will be available to future queries.
Deleting Rows from the Database through ADOIn SQL, rows are deleted from a table using the DELETE command. Which rows are deleted are determined by the WHERE clause, using the |
|||
| [] [返回上一页] [打 印] | |||
|
|||
文章评论 |
|||

