C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,411 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I want to send clob data via command parameters. Please suggest how to do that.
i am also using array of parameters values by using command.arraybindcount.s
dont know how to pass the clob value to command parameters
Is Oracle? Please reference Oracle.ManagedDataAccess
using System.Data;
using Oracle.ManagedDataAccess.Client;
using Oracle.ManagedDataAccess.Types;
class Program
{
static void Main(string[] args)
{
using (var con = new OracleConnection())
{
con.ConnectionString = ".....";
con.Open();
using (var cmd = con.CreateCommand())
{
int arraySize = 3;
cmd.CommandText = "INSERT INTO TEST_CLOB VALUES (:ITEM_CLOB)";
cmd.ArrayBindCount = arraySize;
var p = new OracleParameter("ITEM_CLOB", OracleDbType.Clob, ParameterDirection.Input);
p.Size = arraySize;
p.ArrayBindStatus = new OracleParameterStatus[arraySize];
var values = new OracleClob[arraySize];
for (int i = 0; i < arraySize; i++)
{
var str = i.ToString();
var clob = new OracleClob(con);
clob.Write(str.ToCharArray(), 0, str.Length);
values[i] = clob;
}
p.Value = values;
cmd.Parameters.Add(p);
cmd.ExecuteNonQuery();
for (int i = 0; i < arraySize; i++)
{
values[i].Dispose();
}
p.Dispose();
}
}
}
}