Skip to content

Altibase ADO.NET Development Guide for Windows#

Overview#

This document describes how to develop applications that connect to an Altibase database using C# and ADO.NET on Windows.

It covers the basic development process step by step, from preparing the Altibase ADO.NET Data Provider libraries to configuring a Visual Studio project, connecting to the database, executing SQL statements, inserting data, and handling transactions.

For detailed information on the Altibase ADO.NET interface, refer to the following API manuals.

This document is based on Altibase 6.5.1. If you are using a newer version of Altibase ADO.NET, refer to the API User's Manual for that version. The latest manuals are available on the Altibase Manual page.

Test Environment#

The examples in this document are based on the following environment.

  • Altibase version: Altibase 6.5.1
  • Operating system: Windows 11
  • Development tool: Visual Studio 2026
  • Development language: C#

Info

For errors and improvements related to this document, please contact the technical support portal or technical support center.

Info

This document is provided for informational purposes only and is subject to change without prior notice. It may contain errors, and Altibase makes no express or implied warranties of any kind, including but not limited to warranties of merchantability or fitness for a particular purpose.

The development, release, and timing of any features or functionality described for Altibase products in this document are at the sole discretion of Altibase.

Altibase may hold patents, trademarks, copyrights, or other intellectual property rights related to the contents of this document.

ADO.NET Overview and Key Classes#

ADO.NET is a data access interface that enables .NET applications to access and process data from databases and other data sources in a consistent way.

The .NET Framework Data Provider, one of the components of ADO.NET, handles database connections and data processing. Altibase provides a .NET Data Provider for connecting to Altibase databases.

The key classes used by the Altibase .NET Data Provider are as follows.

Class Description
AltibaseConnection Creates and manages a connection to an Altibase database.
AltibaseCommand Executes SQL statements.
AltibaseDataReader Reads query results sequentially.
AltibaseDataAdapter Transfers data between a DataSet or DataTable and the database.
AltibaseTransaction Starts a transaction and performs Commit or Rollback.

Preparing the Development Environment#

.NET Framework#

The .NET Data Provider included in the Altibase package is recommended for use with .NET Framework 2.0 or later.

If you are using Entity Framework, .NET Framework 3.5 SP1 or later is recommended.

Altibase Windows Client Package#

The .NET Data Provider and CLI libraries required to develop Altibase ADO.NET applications are included in the Altibase Windows Client package.

After installing the client package, you can generally find the related libraries in the following directory:

%ALTIBASE_HOME%\lib

Altibase .NET Data Provider#

Altibase ADO.NET applications use Altibase.Data.AltibaseClient.dll as the .NET Data Provider library.

Altibase CLI Library#

The Altibase .NET Data Provider uses the Altibase CLI library to connect to the database server, so the Altibase CLI library odbccli_sl.dll is required.

DTC Configuration#

If you are using distributed transactions, the Windows Microsoft Distributed Transaction Coordinator (DTC) service must be kept running.

adonet_windows-services

In environments that use XA transactions, you must enable the Enable XA Transactions option in the Local DTC properties.

adonet_xa

This setting is not required for a typical single-database connection environment.

Configuring the Visual Studio Project#

Creating a Project#

Launch Visual Studio and create a new C# project. From the menu, navigate as follows.

File → New → Project

Select a project type that fits your development purpose, such as a Console Application.

adonet_new_project

Adding a Reference to the Altibase ADO.NET Provider#

In Solution Explorer, select the References node of the project and run Add Reference.

adonet_add_references

Select the Altibase.Data.AltibaseClient.dll file to add it as a project reference.

adonet_search_altibase_adonet_library

Once added successfully, you can confirm the Altibase.Data.AltibaseClient library in the References list.

adonet_references_list

Configuring odbccli_sl.dll#

The Altibase ADO.NET Provider requires odbccli_sl.dll at runtime. You must therefore configure the library location so that Windows can locate this DLL.

Method 1. Place it in the same directory as the executable

Copy odbccli_sl.dll to the directory that contains the application executable.

Example:

MyApplication.exe
Altibase.Data.AltibaseClient.dll
odbccli_sl.dll

Method 2. Register it in the PATH environment variable

Add the directory that contains odbccli_sl.dll to the Windows PATH environment variable.

For example, if the file is located in the following directory:

C:\altibase_client\lib

Add that path to PATH.

If you changed the environment variable while Visual Studio was running, you must close and restart Visual Studio for the change to take effect.

adonet_add_path

32-bit / 64-bit Configuration#

The build architecture of the Visual Studio project must match the architecture of the Altibase ADO.NET and CLI libraries.

For example, if you build the application as 32-bit, you must use the 32-bit Altibase ADO.NET and CLI libraries.

32-bit application
→ 32-bit Altibase.Data.AltibaseClient.dll
→ 32-bit odbccli_sl.dll

64-bit application
→ 64-bit Altibase.Data.AltibaseClient.dll
→ 64-bit odbccli_sl.dll

In Visual Studio, you can select whether to build the application as 64-bit or 32-bit through the project options.

adonet_setting_build_bit

If the architectures do not match, errors such as System.BadImageFormatException may occur.

ADO.NET Development Examples#

The Altibase ADO.NET classes were introduced in ADO.NET Overview and Key Classes. This section walks through examples of using these classes in C#.

Connecting to the Database#

AltibaseConnection is used to connect to an Altibase database. The following is a basic example of connecting to Altibase using a connection string.

using System.Collections.Generic;
using System.Linq;
using System.Text;
using Altibase.Data.AltibaseClient;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            String connStr = "DSN=192.168.1.35;UID=sys;PWD=manager;NLS_USE=MS949;PORT=20300";
            AltibaseConnection cn = new AltibaseConnection(connStr);

            try
            {
                cn.Open();
                Console.WriteLine("Successfully connected to Altibase.\n");
            }
            catch (AltibaseException e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                Console.ReadLine();
            }
        }
    }
}

Connection String Parameters

The connection parameters used in the example are as follows.

Parameter Description
DSN IP address of the Altibase server
UID Database user account
PWD Database user password
PORT Service port of the Altibase server
NLS_USE Character set of the Altibase database

Querying Data#

AltibaseCommand is used to execute SQL statements, and AltibaseDataReader is used to read query results sequentially.

The following example converts the SYSDATE value to a string and retrieves it.

AltibaseCommand cm;
AltibaseDataReader dr;

try
{
    cn.Open();
    Console.WriteLine("Successfully connected to Altibase.\n");

    cm = new AltibaseCommand();
    cm.Connection = cn;
    cm.CommandText = "SELECT TO_CHAR(SYSDATE, 'YYYY-MM-DD HH:MI:SS') FROM DUAL";
    dr = cm.ExecuteReader();

    while (dr.Read())
    {
        Console.WriteLine(dr.GetString(0));
    }
}
catch (AltibaseException e)
{
    Console.WriteLine(e.Message);
}

Inserting Data#

AltibaseDataAdapter lets you map data stored in a DataTable to SQL statements and apply it to the database.

The following example inserts data into two columns of the t1 table.

AltibaseConnection cn = new AltibaseConnection(connStr);
AltibaseDataAdapter da = new AltibaseDataAdapter();

try
{

    cn.Open();
    Console.WriteLine("Successfully connected to Altibase.\n");

    da.InsertCommand = new AltibaseCommand("INSERT INTO t1 VALUES (?, ?)", cn);

    DataTable t1 = new DataTable();
    DataRow r1 = null;

    t1.Columns.Add(new DataColumn("C1", typeof(string)));
    t1.Columns.Add(new DataColumn("C2", typeof(int)));

    da.InsertCommand.Parameters.Add(da.InsertCommand.CreateParameter());
    da.InsertCommand.Parameters[0].SourceColumn = "C1";

    da.InsertCommand.Parameters.Add(da.InsertCommand.CreateParameter());
    da.InsertCommand.Parameters[1].SourceColumn = "C2";

    r1 = t1.NewRow();
    r1.ItemArray = new Object[] {"Hong Gil-dong", 23};

    t1.Rows.Add(r1);

    da.Update(t1);
}
catch (AltibaseException e)
{
    Console.WriteLine(e.Message);
}

Handling Transactions#

AltibaseTransaction lets you group multiple SQL statements into a single transaction.

The following example inserts data and then commits it.

AltibaseCommand cm = new AltibaseCommand();
AltibaseTransaction tx = null;

try
{
    cn.Open();

    tx = cn.BeginTransaction();

    cm.Connection = cn;
    cm.CommandText = "INSERT INTO t1 VALUES ('Altibase', 30)";

    cm.ExecuteNonQuery();

    tx.Commit();
}
catch (AltibaseException e)
{
    tx.Rollback();

    Console.WriteLine(e.Message);
}

Common Errors#

When setting up the ADO.NET development environment for the first time, errors may occur due to a mismatch in DLL architecture or issues with the DLL search path.

System.BadImageFormatException#

Symptom#

A first-chance exception of type 'System.BadImageFormatException' occurred in Altibase.Data.AltibaseClient.dll.
A first-chance exception of type 'System.BadImageFormatException' occurred in Altibase.Data.AltibaseClient.dll.
An unhandled exception of type 'System.BadImageFormatException' occurred in Altibase.Data.AltibaseClient.dll.

Cause#

This can occur when the build architecture of the application does not match the build architecture of the Altibase library in use.

For example, if the Visual Studio project is configured to build as a 32-bit application but uses the 64-bit version of odbccli_sl.dll, the application will fail to load the library correctly.

Resolution#

Check the following items together.

  • Verify whether the Visual Studio project's build target is 32-bit or 64-bit.
  • Verify the build architecture of the ADO.NET Provider in use.
  • Verify that the build architecture of odbccli_sl.dll matches that of the application.
  • If necessary, reinstall the Altibase ADO.NET package that matches the project's build target.

In other words, the following three build architectures must match.

Application build architecture = Altibase.Data.AltibaseClient.dll build architecture = odbccli_sl.dll build architecture

System.DllNotFoundException#

Symptom#

An unhandled exception of type 'System.DllNotFoundException' occurred in Altibase.Data.AltibaseClient.dll.
Additional information: Unable to load DLL 'odbccli_sl.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

Cause#

This occurs when Windows cannot locate odbccli_sl.dll, which is required by the Altibase ADO.NET Provider.

Resolution#

Use one of the following two methods.

Method 1. Place the DLL in the same directory as the executable

Application.exe
odbccli_sl.dll

Method 2. Add the DLL directory to the PATH environment variable

Example:

C:\altibase_client\lib

Add that path to the Windows PATH.

If you changed PATH while Visual Studio was running, close and restart Visual Studio.