Maptitude GISDK Help |
This example opens a connection to the GISDK environment, opens a table, and closes the connection to the GISDK environment:
using System;
using System.Collections.Generic;
using System.Text;
using CaliperForm;
///
/// Open a table in the tutorial folder, and select some rows by an SQL-like expression
///
static void Open_Table() {
CaliperForm.Connection Conn = new CaliperForm.Connection
{ MappingServer = mapping_product };
Boolean opened = false;
try {
opened = Conn.Open(log_file);
if (opened) {
// You must declare dk as "dynamic" or the compiler will throw an error
dynamic dk = Conn.Gisdk;
string tutorial_folder = dk.Macro("G30 Tutorial Folder") as string;
// Open a table
string table_name = dk.OpenTable("sales", "ffb", new Object[] { tutorial_folder +
"ctsales.bin", null });
object[] fields = dk.GetFields(table_name, "All");
var field_names = fields[0] as object[];
var field_specs = fields[1] as object[];
// select some records and get record values
dk.SetView(table_name);
int num_rows = dk.GetRecordCount(table_name, null);
string query = "select * where Population > 200000";
int num_found = dk.SelectByQuery("large towns", "several", query, new Object[]
{ new Object[] { "Index Limit", 0 } });
if (num_found > 0) {
string view_set = table_name + "|large towns";
object[] sort_order = null;
object[] options = null;
string order = "Row";
string first_record = dk.GetFirstRecord(view_set, null);
Console.Out.WriteLine(query);
Console.Out.WriteLine(string.Join(",", field_names));
foreach (object[] row in dk.GetRecordsValues(view_set, first_record,
field_names, sort_order, num_found, order, null)) {
string row_values = string.Join(",", row);
Console.Out.WriteLine(row_values);
}
}
dk.CloseView(table_name);
Console.Out.WriteLine();
Conn.Close();
}
} catch (System.Exception error) {
Console.Out.WriteLine(error.Message);
}
}
For more information, see:
Getting Started with CaliperForm
Using the CaliperForm.Connection Class
Using the GISDK Extension Engine In-Process API
See also these specific C# examples for:
©2025 Caliper Corporation | www.caliper.com |