Problem with XmlSerialize on Clob
119014Oct 18 2005 — edited Oct 21 2005I'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();
}
}