PC Review


Reply
Thread Tools Rating: Thread Rating: 2 votes, 1.00 average.

corruption updating a NCLOB field with ODP.Net

 
 
Andy Fish
Guest
Posts: n/a
 
      7th Sep 2007
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
 
 
 
 
Frans Bouma [C# MVP]
Guest
Posts: n/a
 
      10th Sep 2007
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

--
------------------------------------------------------------------------
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
 
Andy Fish
Guest
Posts: n/a
 
      10th Sep 2007

"Frans Bouma [C# MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
:-)

> --
> ------------------------------------------------------------------------
> 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
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to insert NCLOB value with System.Data.OracleClient Andy Fish Microsoft ADO .NET 2 17th Jun 2008 08:40 PM
memo field corruption =?Utf-8?B?V2FsbHk=?= Microsoft Access VBA Modules 7 20th Sep 2006 10:50 PM
Import NCLOB field from Oracle to MS Access 2003 =?Utf-8?B?QWxleA==?= Microsoft Access External Data 2 19th Sep 2006 08:27 PM
Re: Microsoft Provider for Oracle and NCLOB Angel Saenz-Badillos[MS] Microsoft ADO .NET 0 10th Jun 2004 08:40 PM
Re: Microsoft Provider for Oracle and NCLOB Val Mazur Microsoft ADO .NET 0 6th Jun 2004 03:24 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:46 AM.