This sample application describes how to view an UltraLite Database that has large (many rows) tables using the DataGrid control from the .NET Compact Framework. For memory efficiency, the rows are directly read from the database when needed. So therefore, while the data is being displayed, an active connection to the database must be maintained. This approach was taken since the database itself is on the device; and duplicating the data in a DataTable, within the same device, was thought to be redundant.
To generate this memory efficient DataGrid data source, simply add CustomDataSet.cs, CustomTable.cs, CustomTableColumn.cs, CustomTableRow.cs, and ULDotNETBridge.cs classes to the project. You can add the desired iAnywhere.Data.UltraLite.DataReader instance to either a CustomDataSet object or a CustomDataTable object as shown in the sample.
Column and table name mappings can be handled in two ways; using TableMappings on CustomDataSet, and using TableStyles on the DataGrid. Refer to the createTableStyles method of frmDGLargeTables.cs to see how it can be done. Columns may also be renamed by modifying the SELECT statement with AS clauses (not shown in this example).
The database supplied with this sample was taken from the CustDB sample. This sample uses the iAnywhere.Data.UltraLite namespace.
Note: In the Solution Explorer, make sure that the path to the ulnet9.dll is correct. If it is not, then remove it, and add the proper link.
To deploy and run the DataGrid sample, you must first install the appropriate version of ulnet9.dll. This can be done using the Adaptive Server Anywhere for CE Installer (available from the Start menu if you selected this option when you installed SQL Anywhere Studio).
Alternatively, you can add the appropriate version of ulnet9.dll to this project using the Visual Studio .NET menu item "Project > Add Existing Item..." and browsing to the correct ulnet9.dll as listed in the table below. Each time Visual Studio .NET deploys the DataGrid Sample, it will copy the ulnet9.dll to the emulator or device (.NET Smart Device projects do not check to see if native DLLs are already present).
When you change the project's target platform, you will have to remove ulnet9.dll
from the project and then add the version of ulnet9.dll that is
appropriate for the new target platform. This is a limitation of Visual
Studio .NET.
Target platform |
Path to appropriate ulnet9.dll |
|
|
Emulator |
<ASA Install Dir>\ultralite\UltraLite.NET\ce\x86\ulnet9.dll |
ARM/X-Scale device |
<ASA Install Dir>\ultralite\UltraLite.NET\ce\arm\ulnet9.dll |
ARMT device |
<ASA Install Dir>\ultralite\UltraLite.NET\ce\armt\ulnet9.dll |
MIPS device |
<ASA Install Dir>\ultralite\UltraLite.NET\ce\mips\ulnet9.dll |