Search This Blog

Loading...

Sunday, January 15, 2017

Crystal report document load hangs

I faced this problem after I made some changes in Crystal Report design. Somehow in Page Setup dialog box, the printer is changed in drop-down list, pointing to my local PC printer. And it was working fine at local PC but getting stuck when crystal report document is calling its Load() method on server.

Here is how I fixed it in my case:

  • Open report in Crystal Report Designer and Right Click
  • Select Design > Page Setup..., Page Setup Dialog box appears.

  • From the printer drop-down list, select Microsoft XPS Document Writer.

  • Click OK button.

Then I deployed the new report file on server, it stars working.

Monday, December 5, 2016

How can I select from list of values in SQL Server - Table Value Constructor (Transact-SQL)

Table Value Constructor provides a way to construct a table from row value expressions. It allows multiple rows of data to be specified in a single DML statement. One simpler version of select statement with single row values may be used like this:

select 1 as Id, 'ST0258' as ItemCode, 'LASER JET TONER HP 1320 (49A)' as ItemName

But what if we need to select multiple rows with value literals, we need Table Value Constructor. Lets see how we can write similar select statement but with multiple rows.

SELECT Id, ItemCode, ItemName
FROM
  (
    VALUES
  (1, 'ST0258', 'LASER JET TONER HP 1320 (49A)'),
  (2, 'ST0259', 'LASER JET TONER HP 1000 (15A)'),
  (3, 'ST0260', 'LASER JET TONER HP P1005 (35A)'),
  (4, 'ST0261', 'LASER JET TONER HP 540 (CM1312)'),
  (5, 'ST0262', 'LASER JET TONER HP P2035 (05A)')
  )
  AS MyTableName (Id, ItemCode, ItemName)

Its a really cool technique and helps me to save my time while working with small chunks of data or debugging scenarios.

You can also use subqueries to construct row values, but the limitation is that only single scalar values are allowed as a row value expression to construct a single cell value. A subquery that involves multiple columns is not allowed as a row value expression, i.e., you can not specify a subquery with more than one columns to construct multiple cells of a row. For example, the following code will generate syntax error because it contains a subquery constructing more than one columns.

SELECT Id, ItemCode, ItemName
FROM
  (
    VALUES
  (1, 'ST0258', 'LASER JET TONER HP 1320 (49A)'),
  (2, 'ST0259', 'LASER JET TONER HP 1000 (15A)'),
  (3, 'ST0260', 'LASER JET TONER HP P1005 (35A)'),
  (4, 'ST0261', 'LASER JET TONER HP 540 (CM1312)'),
  (5, 'ST0262', 'LASER JET TONER HP P2035 (05A)'),
  (select Id,Item_Code,Item_Name from dbo.items where Item_Code='ST0263')
  )
  AS MyTableName (Id, ItemCode, ItemName)

However, you can rewrite the statement by specifying each column separately in the subquery. The following example code will execute successfully.

SELECT Id, ItemCode, ItemName
FROM
  (
    VALUES
  (1, 'ST0258', 'LASER JET TONER HP 1320 (49A)'),
  (2, 'ST0259', 'LASER JET TONER HP 1000 (15A)'),
  (3, 'ST0260', 'LASER JET TONER HP P1005 (35A)'),
  (4, 'ST0261', 'LASER JET TONER HP 540 (CM1312)'),
  (5, 'ST0262', 'LASER JET TONER HP P2035 (05A)'),
  (
   (select Id from dbo.items where item_code='ST0263'),
   (select Item_Code from dbo.items where item_code='ST0263'),
   (select Item_Name from dbo.items where item_code='ST0263')
  )
  )
  AS MyTableName (Id, ItemCode, ItemName)

References:

Thursday, December 1, 2016

SQL Server Management Studio - Keyboard shortcut CTRL+K, CTRL+C not working

Keyboard shortcuts speed up development tasks in order to get more productive results. I encountered this problem that some keyboard shortcuts stopped working like CTRL+K, CTRL+C is not commenting the selected text, and it seemed unaffected. There could be two possible reasons which may cause this behavior:

  • First check if you have any add-ins installed? Perhaps this is the cause of making default shortcuts not working as expected because an add-in has taken over the control.
  • Second, check the keyboard scheme under Tools > Options > Environment > Keyboard. In my case, it has been switched to SQL Server 2000 you might try switching it back to Standard.

Tuesday, November 15, 2016

Error while publishing LightSwitch Application - 'Web deployment task failed. (This access control list is not in canonical form and therefore cannot be modified.)'

I used to publish my LightSwitch application to a certain location (my folder name is 'IMS2') in wwwroot directory. I have windows 10 installed with Visual Studio 2012 Ultimate. Everything was working smoothly, until I mistakenly deleted the target folder (IMS2), after that when I try to publish LightSwitch application, it starts giving me following error:

Web deployment task failed. (This access control list is not in canonical form and therefore cannot be modified.) C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web\Microsoft.Web.Publishing.targets

After searching and multiple tries I found following two options solved my problem.

  • First, probably the account doesn't have permissions to the target folder (IMS2) you are trying to publish to. Try to publish to a different folder.
  • Second, try reordering the permissions for target folder in IIS Web Server. For this follow these steps:

    1. Open IIS Web Server and select the target website node which is being created by LightSwitch publish wizard.
    2. Right-click on it and select Edit Permissions.

    3. It opens up following dialog box, go to the Security tab, it will prompts that permissions are not incorrectly ordered. Click the OK button.

    4. Within the Security tab, Click the Edit button as shown below:

    5. It will show the following popup asking for Reorder permissions. Click on Reorder button.

    And its done, now restart your Visual Studio instance and try publish the LightSwitch application. This time it should publish your application successfully.

Monday, November 7, 2016

Crystal Reports - Arabic Text or RTL language not showing special characters in correct way.

While developing the Crystal Reports for Arabic language, I encountered the problem that if the Arabic text contains special characters like open/close parenthesis "()", square brackets "[]" or angle brackets "<>" etc., then it was not showing that text correctly while printing the reports. In this post I share what I did to fix my problem, in case if some one else encounter similar problem can benefit from.

For example, I have a text-object. Before setting this option, it was displaying text as follows:

To fix this formatting issue, please follow these steps:

  1. First right click on Text-Object and click on option "Format Object".

  2. Go to Paragraph Tab.

  3. In the Reading order section, check the option Right to Left. As shown below:

And its done. Now it should print the reports with special characters in appropriate state for RTL languages. As my text-object now display this way: