Example 2: Using the Common Programming Model
- Last Updated: May 12, 2026
- 1 minute read
- OpenAccess SDK
- Version 8.1
- Documentation
The following example illustrates connecting to an OpenAccess SDK Server from an application developed in Visual Studio using C# and the Common Programming Model.
-
Check the beginning of your application. Ensure the ADO.NET namespaces are present.
// Access OpenAccess Server using factory using System.Data; using System.Data.Common -
Add the connection information of your server and exception handling code and close the connection.
DbProviderFactory factory=DbProviderFactories.GetFactory("DDTekOpenAccess"); DbConnection Conn = factory.createConnection(); Conn.ConnectionString = "host=test;Port=19986;User ID=test01; Password=test01"; try { Conn.Open(); Console.WriteLine("Connection successful!"); } catch (Exception ex) { // Connection failed Console.WriteLine(ex.Message); } // Close the connection Conn.Close();
For information about using connection strings and connection string options, refer to the OpenAccess SDK Client Reference.