Creates a relate between the Recordset associated with the Layer and a DataTable object.


Namespace: AspMap
Assembly: AspMapNET (in AspMapNET.dll)

Syntax

Visual Basic (Declaration)
Public Function AddRelate( _ 
   ByVal fromField As String,  _ 
   ByVal dataTable As DataTable,  _ 
   ByVal toField As String _ 
) As Boolean
C#
public bool AddRelate(
   string fromField,
   DataTable dataTable,
   string toField
)
C++
public:
 bool AddRelate(
   String fromField,
   DataTable dataTable,
   String toField
) sealed 
J#
public bool AddRelate(
   string fromField,
   DataTable dataTable,
   string toField
)
JScript
public  function AddRelate(
   fromField : String,
   dataTable : DataTable,
   toField : String
) : bool

Parameters

fromField
A string expression that evaluates to the name of a field in the Recordset associated with the Layer.
dataTable
An object expression that evaluates to a DataTable object that contains the data to relate to the Layer object's Recordset.
toField
A string expression that evaluates to the name of a field in the DataTable.

Return Value

The method returns True on success.

Remarks

The AddRelate method creates a join between a Layer and a DataTable. The result is a Recordset which contains all the records from the Layer, and also new attribute fields from the DataTable. The attribute fields have values if a matching value in the fromField and toField is found.

If a primary key index exists for the toField column in the DataTable, it will be used to speed up search for matching values. Otherwise, a temporary index will be created for the column, or the DataTable.Select method will be used.

Example

 Copy Code
SqlDataAdapter adapter = new SqlDataAdapter("SELECT STATE_ID, NAME, TYPE FROM table", "connection string");
adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey; // primary key - STATE_ID
DataTable table = new DataTable();
adapter.Fill(table);
layer.AddRelate("STATE_ID", table, "STATE_ID");

See Also