.net crystal report export to stream from within sql server

1.3k Views Asked by At

Good day, I currently have a crystal report within a console application. I use the following code snippet to get a byte array of the crystal report in pdf to be stored in a table in the database.

Stream stream = cryRpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
 byte[] contents = new byte[stream.Length];
stream.Read(contents, 0, (int)stream.Length);
 stream.Close();

This byte array is passed to a stored procedure which then inserts into a varbinary column in an sql server 2012 database table.

This might sound weird but can someone tell me if this can be done solely on sql server without a console app or web app?

1

There are 1 best solutions below

4
On

You should be able to do it using a CLR function.

You'll basically create a C# class library to expose your pdf conversion function to SQL Server directly. It will all run within SQL Server without requiring an external app.