HighTechTalks DotNet Forums  

corruption updating a NCLOB field with ODP.Net

Dotnet Framework (ADO.net) microsoft.public.dotnet.framework.adonet


Discuss corruption updating a NCLOB field with ODP.Net in the Dotnet Framework (ADO.net) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Andy Fish
 
Posts: n/a

Default corruption updating a NCLOB field with ODP.Net - 09-07-2007 , 10:34 AM






hi,

I am trying to insert/update an NCLOB field using ODP.Net. it seems to
execute OK but the data gets corrupted if I put in more than a couple of Kb
into the field.

here is a complete working example:


create table foo (id int, text1 nclob)


using Oracle.DataAccess.Client;
string connectString = "user id=xxx; password=xxx; data source=xxx";
string commandString = "insert into foo (id, text1) values (2, :1)";
IDbConnection conn = GetConnection(connectString);
IDbCommand cmd = GetCommand(commandString, conn, null);
conn.Open();
IDbDataParameter param = cmd.CreateParameter();
param.ParameterName = ":1";
param.DbType = DbType.String;
param.Direction = ParameterDirection.Input;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 100; i++)
{
sb.Append(i).Append("this is some text").Append(i).Append(";");
}
param.Value = sb.ToString() ;
cmd.Parameters.Add(param);
cmd.ExecuteNonQuery();


If I change the count from 100 to 10 it works OK (no corruption). also an
identical test with the microsoft Oracle provider works without problems.

can anyone tell me what I'm doing wrong?

Many thanks

Andy



Reply With Quote
  #2  
Old   
Andy Fish
 
Posts: n/a

Default Re: corruption updating a NCLOB field with ODP.Net - 09-10-2007 , 05:24 AM







"Frans Bouma [C# MVP]" <perseus.usenetNOSPAM (AT) xs4all (DOT) nl> wrote

Quote:
Andy Fish wrote:

hi,

I am trying to insert/update an NCLOB field using ODP.Net. it seems
to execute OK but the data gets corrupted if I put in more than a
couple of Kb into the field.

here is a complete working example:


create table foo (id int, text1 nclob)


using Oracle.DataAccess.Client;
string connectString = "user id=xxx; password=xxx; data source=xxx";
string commandString = "insert into foo (id, text1) values (2, :1)";
IDbConnection conn = GetConnection(connectString);
IDbCommand cmd = GetCommand(commandString, conn, null);
conn.Open();
IDbDataParameter param = cmd.CreateParameter();
param.ParameterName = ":1";
param.DbType = DbType.String;
param.Direction = ParameterDirection.Input;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 100; i++)
{
sb.Append(i).Append("this is some text").Append(i).Append(";");
}
param.Value = sb.ToString() ;
cmd.Parameters.Add(param);
cmd.ExecuteNonQuery();


If I change the count from 100 to 10 it works OK (no corruption).
also an identical test with the microsoft Oracle provider works
without problems.

can anyone tell me what I'm doing wrong?

Many thanks

Andy

Don't set parameter.DbType, but set the OracleDbType . Also set the
length to 2GB.

FB

Thanks Frans

I didn't see a length parameter, but setting the OracleDbType did the trick
:-)

Quote:
--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.