Example 1: Using the Provider-Specific Objects
- Last Updated: May 12, 2026
- 2 minute read
- OpenAccess SDK
- Version 8.1
- Documentation
The following example uses the provider-specific objects to connect to a database using the data provider from an application developed in Visual Studio using C#.
-
In the Solution Explorer, right-click References, and then select Add Reference.
-
Select the OpenAccess SDK data provider in the component list of the Add Reference dialog box.
-
Click OK. The Solution Explorer now includes DDTek.OpenAccess, the assembly for the OpenAccess SDK data provider.
-
Add the data provider’s namespace to the beginning of your application, as shown in the following C# code fragment:
// Access databaseusing System.Data;using OpenAccess.dll; -
Add the connection information for your server and exception handling code, and close the connection, as shown in the following C# code fragment:
OpenAccessConnection DBConn = new OpenAccessConnection("Host=test; Port=19986;User ID=test01;Password=test01"); try { DBConn.Open(); Console.WriteLine ("Connection successful!"); } // Display any exceptions ddd catch (OpenAccessException ex) { // Connection failed Console.WriteLine(ex.Message); return; } -
Close the connection.
// Close the connection Conn.Close();