I want to upload a large file of size 1Gb to my firebird database. I keep getting a 'System.OutOfMemoryException' thrown at the code below.
FbTransaction trans = conn.BeginTransaction();
string updateSQL = string.Format( @"UPDATE {0} SET {1} = :DATA WHERE {2} RETURNING DATA", tableName, colName, whereStr );
using( FbCommand getBlobCmd = new FbCommand( updateSQL, conn ) )
{
try
{
getBlobCmd.Transaction = trans;
FbParameter parBlob = new FbParameter( "DATA", FbDbType.Binary );
parBlob.Direction = ParameterDirection.Output;
parBlob.Value = File.ReadAllBytes(filePath); //System.OutOfMemoryException
getBlobCmd.Parameters.Add( parBlob );
getBlobCmd.ExecuteNonQuery();
trans.Commit();
}
catch
{
if( trans != null )
trans.Rollback();
}
}
I understand that I need to write data in chunks. But there's no class in .NET data provider with similar functionality. What I need to use in this situation? Thanks!