This is an old revision of the document!
The following is a very simple C# program that shows a basic connection to an Omnidex Environment and simple query processing.
using System; using System.Collections.Generic; using System.Text; using System.Data.Odbc; namespace OdxODBCSample { class OdxODBCSample { static void Main(string[] args) { Console.WriteLine("Omnidex Sample C# Program"); string connString = @"DRIVER={Omnidex};CONNECTIONSTRING=[server1:7555]c:\class\simple.xml"; string sqlselect = "select NAME, PHONE from INDIVIDUALS"; OdbcConnection conn = null; OdbcDataReader reader = null; try { // Open Connection conn = new OdbcConnection(connString); conn.Open(); // Execute the SQL statement OdbcCommand cmd = new OdbcCommand(sqlselect, conn); reader = cmd.ExecuteReader(); // Display output header Console.WriteLine("NAME\tPHONE"); // Process the result set while(reader.Read()) { Console.WriteLine( "{0}\t{1}" , reader["NAME"].ToString().PadLeft(10) , reader["PHONE"].ToString().PadLeft(10) ); } } // try catch (Exception e) { Console.WriteLine("Error: " + e); } finally { if (reader != null) reader.Close(); if (conn != null) conn.Close(); } } // end main } // end class } // end namespace
See also: