Tuesday, 19 April 2016

No result is rendered in Preview mode when using Crystal reports in .NET web application

We encountered this issue with several different reports on different servers. The report would render fine in other modes such as Microsoft Excel or PDF. But when viewing in the default Preview mode, we are not able to see anything loaded and just a blank page. There is no specific information or error logged, either.

All reports may have been working at one stage on the same server before. It can be likely related to the reinstall of Crystal Report runtime on the server but we are not sure the definite cause of the problem. However, the solution is to copy the files according to the steps below.

1) Run the report as usual while having the browser’s dev tool open and Network monitor is running
2) While the report is loading in Preview mode, you will find there will be some 404 error appears in the monitor screen
3) Once the page is loaded, check the 404 error details and see what files were missing
4) The file path would be something starts with c:\inetpub\wwwroot\aspnet_client
5) Navigate to the file path. The two folders that start with 4_0 and 2_0 may contain same files. So you can modify the folder name and copy the right files accordingly. If a folder is completely missing, you may create a new one and copy the content from the existing 4_0 folder.

Note: if your virtual directory is not hosted on the c:\, you may need to do this to the same drive and the entire c:\inetpub folder is required on that drive as well.

Thank you for the person who posted the solution here and there are some variations of this problem that can be fixed in the same way.

Friday, 15 April 2016

SQL server database collation explained

When we installing a new SQL server instance, we have to choose a database collation. This will be the default collation for all databases that going to be created on this instance later on.

However, this default database collation can be overridden in following ways.

1. When creating a new database, we can specify a different collation for the database.

For example

CREATE DATABASE DbWithNewLanguage COLLATE SQL_Latin1_General_CP1_CI_AS

2. When creating a new table, we can specify different collations for individual column.

For example

CREAT TABLE MixLanguageTable (
ID INT IDENTITY,
EnglishName nvarchar(150) COLLATE Latin1_General_CS_AS,
GreekName nvarchar(150) COLLATE Greek_CS_AS_KS,
JapaneseName nvarhcar(150) COLLATE Japanese_90_CI_AS_KS_WS
)

3. When querying the tables, we can specify different collations.

For example

--EnglishName column in the example above is case sensitive. But we can change the collation so when we query the table on this column, we can set it to be case insensitive.

SELECT * FROM dbo.MixLanguageTable WHERE EnglishName = ‘test name’ COLLATE Latin1_General_CI_AS