Creating a Table

Before you can manipulate data with the ADOCE control from within an application, you must have a database or table available in which to store the data. You can either open an existing ADOCE table or create a new table in the Databases directory on the Windows CE–based device. Use the Open method of the Recordset object to open or create a table. Once the Recordset object is instantiated, and a table is opened using the Open method, you can manipulate the data in the table.

The following code example shows how to open an existing ADOCE table.

Dim rs
Set rs = CreateObject("adoce.recordset")
rs.Open "myTable"   'Opens the table "myTable"

The following code example shows how to create a new ADOCE table in the Databases directory of a device.

Dim rs
Set rs = CreateObject("adoce.recordset")
'The next line creates a table named myTable using 
'a SQL statement as a variable in the Open method.
rs.Open "create table myTable (firstfield text, secondfield integer)"
Set rs = Nothing

Remarks

SQL statements that change the structure of a table leave the recordset closed. When you create a table you must close it and reopen it in order to read or write data.

You can open a .cdb file on the device by specifying the name of the .cdb file in the ActiveConnection parameter of the Open method.

For more information on SQL statements, see SQL and ADOCE.