31 March 2012

Convert String to Number in Crystal Reports

Use a Crystal formula to convert string field to Number by using the ToNumber function.
Example: 
ToNumber({Table.Column})


To convert any Numeric field to Text by using the ToText function.
Example:
ToText({Table.Column})
This will allow you to use String functions (i.e. Mid, Left, etc) on any Numeric field.

Hide fields in Crystal Report

To hide any formula value or field values.  Select field and right click on it then context menu displays select Format Editor as shown below screen shots.
Step 1:
Step 2:

20 March 2012

Using Session State in a Web Service

In my web application i have used web services many time. Now i need to pass session variable to the web service method to get data form the database based on the session value. When i am passing session value I got an error. After searching i found the solution to use HttpSession in web methods. It is very simple to resolve this issue i.e enable the session state before using it. This can be done by using following attribute.
[WebMethod(EnableSession=true)] //C#
<WebMethod(EnableSession:=true)] 'VB.net

Example: 
Passing Session value
Session["Value"] = 3; 
Access this session variable (Session["Value"] ) in Add Web Method.
Example:

[WebMethod(Description = "adds x , y and  Value session")]
public int Add(int x, int y)
{
   return (x + y) + (int)Session["Value"] ;
}
This will not work and throws an error. To avoid this needs to enable session state in each web metods.
Example:
[WebMethod(EnableSession = true, Description = "adds x , y and  Value session")]
public int Add(int x, int y)
{
return(x + y) + (int)Session["Value"] ;
}
Once you specify these lines over your web method you can use the session object naturally.

19 March 2012

C# - Error: Could Not Load File Or Assembly 'Microsoft.ReportViewer.WebForms, Version=9.0.0.0

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. 

Solution 
This error means you're using the SQL Server Reporting Services/Crystal Reports  ReportViewer control in your web application, and the server can't find the proper DLL. All you have to do is deploy them to your server. With Visual Studio 2008, the location of the ReportViewer DLLs has changed. 
You now find them at C:\Program Files\Microsoft Visual Studio 9.0\ReportViewer.
The first way to get these on your server, and this only works if you run your own server, is to directly copy them into the C:\Windows\assembly folder, and reboot the server (this reloads the GAC). If a reboot is out of the question, you can use GACUTIL.EXE to copy and register the DLLs. 
If you're in a shared hosting environment, reference the DLLs from the VS 9 path listed above, and set the Copy Local=True (select the DLL and open the Properties tab). This will copy the DLLs into your applications BIN folder, and look for them there first. You can then deploy to a shared host, making sure to copy all the contents of BIN.


Dll name 
paste following dll in bin folder or windows folder
1> Microsoft.ReportViewer.Common.dll
2> Microsoft.ReportViewer.ProcessingObjectModel.DLL
3> Microsoft.ReportViewer.WebForms.dll
4> Microsoft.ReportViewer.WinForms.dll

13 March 2012

Windows 7, IIS 7.5 Images, CSS not showing!

Web site having ASP.NET themes. Theme including a CSS file in it, the CSS file was linked in the generated HTML but clearly it was not applied. Putting the URL of the CSS file in the browser address bar would return an empty result in Firefox, and a crappy DOCTYPE,HTML,HEAD,BODY tags in IE. The same website works normally with other developers running Windows XP or Windows 7.
I tried change the website from custom Application Pool to default integrated pipeline one to default classic (IIS 6 like) one, but no use.
Here’s what the problem was:  
While installing IIS 7.5 for the first time, needed to choose  “Static Content” checked as well to display images in the website.