CrystalReports Export Issue

Today I was stuck up with exporting crystal reports from an ASP.NET application. It was throwing the following exception

Error in File C:\DOCUME~1\NAMO1\ASPNET\LOCALS~1\Temp\temp_ea29ba79-be60-4bd1-8422-671b26d615ae.rpt: Error detected by export DLL:

Anybody got this before. If yes and you are using any BLOB field in report datasource, then continue reading. This post explains a solution for this problem.

In my crystal report I am binding dynamic images. It’s a report file which print packing slip, and the company logo was a user specified one. It’s working with setting a datatable contains BLOB data ( Image ) as datasource for the report.
Workaround

Crystal reports can show only jpg and bmp type of images. This error comes when any unsupported image files are binded. Make sure that image file you are binding is not a gif file. It should be a jpg/bmp file.

Advertisements

Writing a long string in multiple lines – c#

Writing a big string will always produce scrollbars in the editor. So it’s better to split it to multiple lines which is more easy to read. This post discusses the various methods that can be used to split big lines into multiple lines.

Check this big line.

string BigLine = "bla bla  bla bla  bla bla  bla bla  
bla bla  bla bla  bla bla  bla bla ";

Writing a string as shown above will produce error. This can be rewritten like

string BigLine = @"bla bla  bla bla  bla bla  bla bla  
bla bla  bla bla  bla bla  bla bla ";

Or

string</font> BigLine = "bla bla  bla bla  bla bla  bla bla " +
"bla bla  bla bla  bla bla  bla bla ";

I always prefer the second one. Because first one will not move the next line to the starting of first line. And more over it won’t be possible to write first method for the following type of string.

string BigLine = @"bla bla  bla bla  bla bla  bla bla  
bla bla  bla bla  bla bla\"test\"  bla bla ";

In this I am escaping " by specifying \. But .NET editor will produce an error.

Rounding decimal point value – SQL Server

To round value into fixed decimal points, we need to make use of convert function. Convert the value in to decimal type by specifying decimal points. Following function rounds value into two decimal points

CREATE FUNCTION RoundMoney (@Value money)
RETURNS Varchar(50) AS
BEGIN
Declare @ReturnValue varchar(50)
Set @ReturnValue = ( Select CONVERT(decimal(12,2),@Value ) )
Return (@ReturnValue)
END

Getting parameter name from SQL Stored Procedure

I was trying to create an application which looks like SQL Enterprise manager using C#. I struggled with getting parameter name’s which is present in a Stored Procedure. Following query gives you all the parameters used in stored procedures.

SELECT * FROM INFORMATION_SCHEMA.PARAMETERS

Yes the above query will give all parameter in all stored procedures present in database. To filter with procedure specific parameters, use the following

SELECT * FROM INFORMATION_SCHEMA.PARAMETERS WHERE
specific_name = ‘ProcedureName’

Happy querying