OceanBase
English日本語简体中文
Docs Home
Products
Integrations
Release Notes

Databases

OceanBase DatabaseOceanBase Cloud OceanBase Best Practices

Tools

OceanBase Cloud PlatformOceanBase Migration ServiceOceanBase Developer CenterOceanBase Migration AssessmentOceanBase Admin ToolOceanBase Loader and DumperOceanBase DeployerKubernetes operator for OceanBaseOceanBase Diagnostic Tool OceanBase Binlog Service

Connectors and Middleware

OceanBase Database Proxy OceanBase Connector/C OceanBase Connector/J OceanBase Connector/ODBC OceanBase Connector/NETOceanBase Command-Line Client

Databases

OceanBase DatabaseOceanBase Cloud OceanBase Best Practices

Connectors and Middleware

OceanBase Database Proxy OceanBase Connector/C OceanBase Connector/J OceanBase Connector/ODBC OceanBase Connector/NETOceanBase Command-Line Client

Tools

OceanBase Cloud PlatformOceanBase Migration ServiceOceanBase Developer CenterOceanBase Migration AssessmentOceanBase Admin ToolOceanBase Loader and DumperOceanBase DeployerKubernetes operator for OceanBaseOceanBase Diagnostic Tool OceanBase Binlog Service
OceanBase DatabaseOceanBase Cloud ToolsConnectors and MiddlewareLifecycle Support Policy

OceanBase Connector/NET

V1.3.0
  • What Is OceanBase Connector/NET
    • Overview of OceanBase Connector/NET
  • Install and Connect
    • Installation process
    • Test the connection
    • Package reference and usage
    • Compatibility impact
  • User Guide
    • Quick Start
      • Complete example
    • Connection Strings and Data Source
      • Connection string
    • Data Types
      • Overview of data types
      • User-defined types (UDTs)
    • Command and Parameter
      • Overview
      • ArrayBinding
    • Result Set
      • Supported result set types
    • ORM and Frameworks
      • Use Entity Framework Core
      • Use SqlSugar
      • Use FreeSql
  • Reference Information
    • Common Interfaces
      • Overview of commonly used interfaces
  • Version Release Records
    • OceanBase Connector/NET V1.0.0
    • OceanBase Connector/NET V1.1.0
    • OceanBase Connector/NET V1.2.0
    • OceanBase Connector/NET V1.3.0

Download PDF

Document Feedback
  1. Documentation Center
  2. OceanBase Connector/NET
  3. V1.3.0

Complete example

Last Updated:2026-09-22 02:27:11

The following example shows the complete process of connecting to a database, executing SQL statements, and reading the result set by using OceanBase Connector/NET. The API usage is similar to that of Oracle ODP.NET. For more information about how to reference packages, see Reference and use packages.

using Oracle.ManagedDataAccess.Client;

var connectionString = "Data Source=host:port;User Id=username@tenant_name#cluster_name;Password=password;Database=schema_name;";
using var conn = new OracleConnection(connectionString);
conn.Open();

using var cmd = conn.CreateCommand();
cmd.CommandText = "CREATE TABLE test_table(a VARCHAR2(100))";
cmd.ExecuteNonQuery();

cmd.CommandText = "INSERT INTO test_table VALUES(:a)";
cmd.Parameters.Add(new OracleParameter("a", "abc123"));
cmd.ExecuteNonQuery();

cmd.CommandText = "SELECT * FROM test_table";
cmd.Parameters.Clear();
using var reader = cmd.ExecuteReader();
while (reader.Read())
{
    Console.WriteLine("c1=" + reader.GetValue(0).ToString());
}

conn.Close();

Note

For more information about the connection string format, see Connection strings. In Oracle mode, you must specify the Database (schema). For more information about the supported commands and limitations of OracleCommand and OracleDataReader, see Overview of commands and Types of result sets.

Previous topic

Compatibility impact
Last

Next topic

Connection string
Next