AddODBCLayerToWorkspace()

Summary

Adds an ODBC layer to an application without it appearing in a map or dataview.

Syntax

AddODBCLayerToWorkspace(string layer_name, string service_name, string db_layer_name, string schema_name, array options)

Argument Contents
layer_name The desired name for the layer in the map
service_name The name of the ODBC service
db_layer_name The name of the ODBC table
schema_name The name of the ODBC schema if necessary, otherwise null
Option Type Contents
Fields 3 strings The names of the fields with the ID, X and Y values (required)
Read Only Boolean "True" to open read only, "False" (default) otherwise
NAD Conversion 3 strings Input datum, output datum, and conversion file (if needed); the input and output datums should be different
Projection String, array The projection name and the array of options
Transform Array Array specifying the coordinate transformation to apply to the file. This array can take one of three forms: (1) Control Point Transform an array of two or more four-element arrays containing local and world coordinates for control points. Example: {{real localX1, real localY1, real longitude1, real latitude1}, ...}. (2) Affine Transform an array of four elements: {real X_multiplier, real Y_multiplier, real X_offset, real Y_offset}. (3) Center and Extent Transform {c1_x, c1_y, width_1, c2_x, c2_y, width_2}, where the center shifts from (c1_x, c1_y) to (c2_x, c2_y), and a vector of length width_1 from c1 becomes a vector of length width_2 from c2.

Returns

A string indicating the actual name of the layer, which is identical to layer_name unless the layer name is already in use.

Notes

  • The Fields option is required.

  • If the coordinates are longitude and latitude with implied decimal places, you must use the Transform option to multiply them by the appropriate factor to get decimal degrees. For example, if there are six implied decimal places, multiply by .000001.

  • For more details on the NAD Conversion option, see Datum Conversions.

  • For more details on the Projection option, see Using Projections and Coordinate Systems.

Example

lyr = AddODBCLayerToWorkspace("Cities", "myservice", "US City", "US Data",
{{"Fields", "ID", "Lon", "Lat"}})
nrecs = GetRecordCount(lyr)
DropLayerFromWorkspace(lyr)
ShowMessage("There are " + String(nrecs) + " cities.")

Error Codes

Error Type Meaning
Error The service is not a valid ODBC database, or one of the parameters is invalid
NotFound There is no service with the specified name

See Also

Function Summary
AddODBCLayer() Adds an ODBC layer to a map
AddSDOLayerToWorkspace() Adds a layer from an Oracle Spatial table to an application without it appearing in a map or dataview