I am able to create PDF's from my Telerik report very easily, and it works great. I want to save that report to the database, so it doesn't have to regenerate every time. It is not saving for some reason to the database, and I know that I can do this with other PDF byte arrays in other pieces of my code. Is something different with the Telerik Byte Array? Both below save data with other PDF byte arrays, but not the telerik report. What am I doing wrong? When I debug, both have values in the byte array, reportBytes.
Example 1, VB does not work: (param1 is passed in as an integer)
Dim reportBytes As Byte()
Dim mimeType As String = String.Empty
Dim ext As String = String.Empty
Dim encoding As Encoding = encoding.Default
reportBytes = Telerik.Reporting.Processing.ReportProcessor.Render("PDF", report, Nothing, mimeType, ext, encoding)
asqlConnection = GF_GET_DATABASE_CONNECTION()
Dim sql As String = "UPDATE TABLE SET PDF = @reportBytes where xxx=" & CType(param1, String)
Dim cmd As SqlCommand = New SqlCommand(sql, asqlConnection)
cmd.Parameters.AddWithValue("@reportBytes", reportBytes)
Dim id As Integer = cmd.ExecuteNonQuery()
Example 2, C# does not work (param1 is passed in as an integer):
byte[] reportBytes =ReportProcessor.Render("PDF", reportToExport, null,out mimeType, out ext, out encoding);
Database db = DatabaseFactory.CreateDatabase("ConnectionString");
DbCommand dbCommand = db.GetSqlStringCommand("update TABLE set PDF = @imageData where xxx=" + param1);
db.AddInParameter(dbCommand, "@imageData", DbType.Binary, reportBytes);
int ret = db.ExecuteNonQuery(dbCommand);
dbCommand.Dispose();
Example 1, VB does not work: (param1 is passed in as an integer)
Dim reportBytes As Byte()
Dim mimeType As String = String.Empty
Dim ext As String = String.Empty
Dim encoding As Encoding = encoding.Default
reportBytes = Telerik.Reporting.Processing.ReportProcessor.Render("PDF", report, Nothing, mimeType, ext, encoding)
asqlConnection = GF_GET_DATABASE_CONNECTION()
Dim sql As String = "UPDATE TABLE SET PDF = @reportBytes where xxx=" & CType(param1, String)
Dim cmd As SqlCommand = New SqlCommand(sql, asqlConnection)
cmd.Parameters.AddWithValue("@reportBytes", reportBytes)
Dim id As Integer = cmd.ExecuteNonQuery()
Example 2, C# does not work (param1 is passed in as an integer):
byte[] reportBytes =ReportProcessor.Render("PDF", reportToExport, null,out mimeType, out ext, out encoding);
Database db = DatabaseFactory.CreateDatabase("ConnectionString");
DbCommand dbCommand = db.GetSqlStringCommand("update TABLE set PDF = @imageData where xxx=" + param1);
db.AddInParameter(dbCommand, "@imageData", DbType.Binary, reportBytes);
int ret = db.ExecuteNonQuery(dbCommand);
dbCommand.Dispose();