Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problem with XmlSerialize on Clob

119014Oct 18 2005 — edited Oct 21 2005
I'm trying to serialize an object to an OracleClob and send that to a stored procedure on the database.

The problem that I'm having is that after serializing, the Clob value is all garbage.

I read that declaring a Clob this way creates a temp clob and that you don't need to create a transaction to use one, but I tried creating a transaction anyway and it still didn't help.

Here is my code below.

public void AddSessionLargeVar(string sVarName,object VarValue)
{
// init command object
InitAddSessionLargeVar();

XmlSerializer xs=new XmlSerializer(VarValue.GetType());

OracleTransaction t=cnCon.BeginTransaction();

try
{
// why is this writing garbage to the OracleClob?
OracleClob clob=new OracleClob(cnCon);

xs.Serialize(clob,VarValue);

addSessionLargeVarCmd.Parameters["dtVarName"].Value=sVarName;
addSessionLargeVarCmd.Parameters["dtVarValue"].Value=clob;

addSessionLargeVarCmd.ExecuteNonQuery();
clob.Dispose();
t.Commit();
}
catch(Exception ex)
{
t.Rollback();
}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 18 2005
Added on Oct 18 2005
17 comments
2,678 views