Data binding – Pitney Bowes MapXtreme User Manual

Page 176

Advertising
background image

Chapter 8: Working with Data

Table Metadata (TableInfo)

MapXtreme v7.1

183

Developer Guide

ti.KeyColumns = sc
ti.KeyType = KeyType.Explicit

' Ask the Catalog to open the table.

Dim tbl As Table = connection.Catalog.OpenTable(ti)

' Now the MICommand object may be used to select data from the table
' (by the name EuropeanCities since that is the alias we assigned to
' it). The data in thistable may be joined with any other table and
' it may be used as source data in a call to AddColumns to populate
' temporary columns with data from this table.
End Sub

Data Binding

Data binding is the process of bringing data from a data source into MapXtreme. Data binding of
external data (ADO.NET and other legacy sources) to MapInfo.Data.Table is accomplished by
opening an ADO.NET DataTable as a Table using TableInfoAdoNet. The table can then be joined
with another table, joined to itself or use Table.AddColumns to bind columns to a second table.

To join a table to itself, following this example:

Select ... From T as A, T as B Where A.X = B.Y

If an application has data stored in a DataTable or data that is accessible through an ADO.NET data
provider, that data can be presented to the Catalog and treated as a MapInfo table. This would be
primarily useful if the data were not accessible through one of the other table types.

For example, if the data is stored in a dBase file, Microsoft Access table, or is accessible through
ODBC or Oracle's OCI interface, it is recommended that those TableInfo types be used to access
the data. Data which cannot be accessed through one of these types of tables, but that can be
loaded into a DataTable or is accessible through some ADO.NET Data Provider that implements the
Command, Parameter and DataReader object types can still be accessed by the Catalog.

An application may need to make data available as a MapInfo native table so that queries can be
executed to join the data with other MapInfo table data. It may also need to be made available to the
Catalog so it can be used as the source data in a call to the Table.AddColumns.

Code Example: How to Join Data from an Oracle Table

public Shared Sub MapInfo_Data_TableAddColumns5(ByVal map As Map)

Dim Connection As MapInfo.Data.MIConnection = New _

MapInfo.Data.MIConnection

Connection.Open()

'Add the USA table to the map

map.Load(New _

MapInfo.Mapping.MapTableLoader("C:\\maps\\usa.TAB"))

Dim lyr As MapInfo.Mapping.FeatureLayer = map.Layers("usa")

' Open the table from Oracle

Advertising