|
|
|
Introduction |
This PalmDB provider is developed for developers who want to create Palm database
(PDB) file on desktop or laptop and then install it on Palm devices. To use the
provider to create PDB shall be as easy as A, B, and C as long as you have a little
bit experience with ADO and SQL. You may also use this provider to view records
in existing PDB files or to modify existing PDB files. In other words, you can use
it to read records from and/or write records to PDB files.
This provider uses SQLite engine for data manipulation because SQLite is lightweight
and very fast. Refer to
the SQLite Website to find more information about SQLite if you are
interested in it. If you do not have much experience about ADO, please refer to
the pages about SQLite OLE DB Provider, MySQL OLE DB Provider
and Firebird OLE DB Provider
Those pages shall give you a clue on how to use ADO. Actually, even if you know
nothing about SQL and ADO, you still can fellow me to create PDB files easily.
|
|
Architecture |
As mentioned above, PalmDB Provider can be used with ADO or ADO.NET. You may use
PalmDB Provider in your .NET, VB, and C++ (native) applications.
The right side diagram depicts the Architecture of the data access in your application.
On the top is your application. You application can interface PalmDB Provider directly.
You may also choose to interface this provider indirectly via ADO/ADO.NET.
At the bottom are 3 files, PDB Schema definition file, existing PDB file, and new
PDB file. The PDB Schema file defines the PDB table columns so that PDB records
can be easily manipulated with SQL queries. The existing PDB file is optional. If
this file is supplied, records in this PDB will be retrieved based on the schema
defined in the schema file and put into temporary SQL table. Then you may read/delete/add/update
the records in the temporary table. At the very end, you can execute one single
provider specific to flush out all records into a New PDB File. |  |
|
|
Features |
The following are the features that this PalmDB Provider supports:
- Transaction
- Record scroll
- Parameters
- Bookmarks
- Database Schema - tables and their columns
- Extended error information
- Multiple queries in one single execution
|
|
PalmDB Provider Connection String |
"Provider=OlePDB.PalmSource; Data Source=PDBFileFullPath; Schema=PDBSchemaFileFullPath; Table Name=PDBTableName;Creator ID=PDBCreatorID;"
where- PDBFileFullPath - full path of an existing PDB file from which you want to read
records. If you do not want to read any existing PDBs, leave it blank.
- PDBSchemaFileFullPath - the full path of the schema file that defines the PDB table
schema. The schema is used to interpret an existing PDB file and/or define a new
PDB table to be created. For schema definition, refer to section Working With PalmDB
Provider.
- PDBTableName - Name of a PDB to be created. 1 to 32 characters long.
- PDBCreatorID - creator ID of a PDB to be created. Must be 4 characters long.
|
|
PalmDB Provider Specific Query |
PalmDB defines only one provider specific query to write records to a new PDB file:
FLUSH INTO [PDBFile] ORDER BY ...
where PDFile is the full path of a new PDB file to be created. '[' and ']' are mandatory too. ORDER BY clause is optional
|
|
Working With PalmDB Provider |
Creating a Palm database (PDB) is as easy as A, B and C using PalmDB Provider.
- Create your PDB schema
with an XML file
- Create an ADO connection to a PDB file via
PalmDB Provider
- Insert data into the data and call FLUSH to
create the PDB file
|
You shall be able to follow 3 steps above to create your PDB file very easily.
If you have any problems, feel free to send us feedback.
Here are more details a long with sample code.
Step A: Create PDB schema and save it to file. This file will be used in step B.
The PDB schema definition sample includes all data types this PalmDB Provider supports.
<root>
<!--columns must reflect PDB table schema.
This is a schema for demostration-->
<column>
<name>i8</name>
<datatype>tinyint</datatype>
<!--datasize>do not need size for tinyint </datasize-->
</column>
<column>
<name>i16</name>
<datatype>smallint</datatype>
<!--datasize>do not need size for smallint</datasize-->
</column>
<column>
<name>i32</name>
<datatype>int</datatype>
<!--datasize>do not need size for integer</datasize-->
</column>
<column>
<name>r4</name>
<datatype>float</datatype>
<!--datasize>do not need size for float</datasize-->
</column>
<column>
<name>r8</name>
<datatype>double</datatype>
<!--datasize>do not need size for double</datasize-->
</column>
<column>
<!--PDB will store exactly number bytes specified with
the dataszie.If the string is shorter, stored string
will trail with blank spaces-->
<name>fc</name>
<datatype>char</datatype>
<datasize>10</datasize>
</column>
<column>
<!--PDB will store up to the number bytes specified with
the datasize. However, if the string is shorter, the
data stored will be null terminated string. If the
string is exactly the same as what the datasize
specified, the stored data will be the string without
null-->
<name>vc</name>
<datatype>varchar</datatype>
<datasize>10</datasize>
</column>
<column>
<!--Data storage is similar to the Char type above. However,
if number bytes is fewer than the datasize specified,
data stored will be trailed with zeros. -->
<name>fb</name>
<datatype>binary</datatype>
<datasize>30</datasize>
</column>
<column>
<!-- The first two bytes store the length of the byte array
then the data with no more than the number specified by
the datasize-->
<!--The datasize can be 0 for varbinary type only if the
column is the last column in the table. In this case,
the binary data without the # of the real data size.
You may stored as many bytes as you want provided the
overall record size is not over PDB record size-->
<name>vb</name>
<datatype>varbinary</datatype>
<datasize>4000</datasize>
</column>
</root>
Step B: Create an ADO connection to a PDB file via PalmDB Provider
To open ADO connecton to a PDB file via PalmDB Provider, Provider, Data Source, Schema, Table Name and Create ID must be provided in the ADO connection string.
Here is a sample ADO connection string:
"Provider=OlePDB.PalmSource; Data Source=C:\public\MySource.pdb; Schema=c:\public\PDB.schema.xml; Table Name=Tbl_test; Creator ID=SEAN"
Where Provider must be "OlePDB.PalmSource"; Data Source shall be the PDB file path and name; Schema shall be the PDB schema definition file path and name;
Table Name shall be the PDB table name; and Creator ID shall be the PDB creator ID. If you
do not want to read data from existing PDB, leave data source empty.
Step C: Insert data into database and create PDB file
Once you have an open connection to the PDB file via ADO, you may execute SQL queries to insert data into the PDB. Always execute command "FLUSH INTO [file name];" in order
to generate PDB file.
Below is the sample code for steps B and C.
Private Sub test_Click()
On Error GoTo trap
Dim conn As New Connection
Dim connStr as String
connStr = "Provider=OlePDB.PalmSource; " _
& "Data Source=; " _
& "Schema=c:\public\PDB.schema.xml; Table Name=Tbl_test;" _
& "Creator ID=SEAN"
conn.Open connStr
Dim cmd As New ADODB.Command
cmd.ActiveConnection = conn
cmd.CommandText = "insert into Tbl_test (i8, i16, i32, r4, r8, fc, vc) " _
& "values (1, 2, 3, 1.1, 2.2, 'my', 'God');"
cmd.Execute
cmd.CommandText = "insert into Tbl_test (i8, i16, i32, r4, r8, fc, vc) " _
& "values (11, 22, 33, 1.1, 2.2, 'my', 'God');"
cmd.Execute
Dim fb(29) As Byte
Dim vb(29) As Byte
Dim I As Integer
For I = 0 To 29
fb(I) = 10 + I
vb(I) = 100 + I
Next I
Dim p(1) As New ADODB.Parameter
p(0).Type = adBinary
p(0).Value = fb
p(0).Size = 30
p(1).Type = adBinary
p(1).Value = vb
p(1).Size = 30
cmd.CommandText = "UPDATE Tbl_test SET fb=?, vb=?;"
cmd.Parameters.Append p(0)
cmd.Parameters.Append p(1)
cmd.Execute
cmd.CommandText = "FLUSH INTO [C:\public\MySource.pdb];"
cmd.Execute
conn.Close
Set conn = Nothing
Exit Sub
trap:
MsgBox Err.Description
End Sub
Here is another sample application written in C#. You may write SQLite queries to
insert and/or change records and then commit your changes into a new PDB File by
executing the 'flush' command.
You may use the sample application shown on the right side to get familiar with the PalmDB
Provider. The download includes a PDB table schema definition file. No PDB files
are included. You may leave PDB Source blank and create a new PDB file.Then use the newly created PDB file as PDB source and read the data back.
|
 |
You may type your queries in the text area and then select each query to execute. Once you have get all records into the database, execute the last command to flush out records into a PDB file.
|
|
Activation |
PalmDB Provider must be activated before you can use it. To activate it, you must
download the provider and get your pass code from the ActUtil included in the download.
Click
here to get activation code. |
|
Download |
Update History:
| Date | Changes |
| 2007-01-20 | Fixed an activation defect. |
| 2006-09-12 | Added a new feature such that it can read/modify existing PDB files. |
| 2006-03-05 | Fixed a critical activation bug. |
| 2006-01-02 | Fixed a binary input parameter binding issue. |
| 2005-11-27 | Upgraded to support ADO.NET 2.0. |
| 2005-11-12 | Initial public release. |
PalmDB Provider
C# sample source code
PalmDB VB sample code
|
|
Disclaim |
This whole post here including the downloads is provided 'as-is', without any express
or implied warranty. In no event will the author be held liable for any damages
arising from the use of this software. |
|
Feedback |
To send me feedback, click
here |
|