Wednesday, May 27, 2009

System.Runtime.InteropServices.COMException: The system cannot find the file specified

[COMException (0x80004005): The system cannot find the file specified.]
This Error occurs when using crystal reports as web reporting.

There are several reasons for this.
  • Required DLL are missing in web setup
  • Required Reports files are missing in web setup
  • Access Permisions
Required DLL and Reports are missing in web setup

To over come this you can create web setup as below (VS2008)

Go to Other Projects , Add Web Set up Project.

Then Right Click the Project and goto Properties and then Prerequisites and select
crystal Reports Basic for Visual Studio..

And add other files (sometimes reports files are not including please be careful)

Note:- If your error is still occur use filemon (google it and get the first link) and monitor your files when browsing. it will give what is the actual cause of the error.

Access Permission

Give full permission to (give permissions in IIS , Windows/Temp, wwwroot )

Read From Application Configuration File C#.Net

Add App.config File Using Add New Item

Open the Configuration File and add relevant Entries.

Method 1

using System.Configuration;

String Value=ConfigurationSettings.AppSettings.Get("SampleKey1");
int SampleInt = Convert.ToInt32(ConfigurationSettings.AppSettings.Get("SampleKey2"));

Tuesday, May 26, 2009

String Format C#.NET

just two decimal places
String.Format("{0:0.00}", 123.4567); // "123.46"
String.Format("{0:0.00}", 123.4); // "123.40"
String.Format("{0:0.00}", 123.0); // "123.00"

max. two decimal places
String.Format("{0:0.##}", 123.4567);              // "123.46"
String.Format("{0:0.##}", 123.4); // "123.4"
String.Format("{0:0.##}", 123.0); // "123"

at least two digits before decimal point

.Format("{0:00.0}", 123.4567); // "123.5"
String.Format("{0:00.0}", 23.4567); // "23.5"
String.Format("{0:00.0}", 3.4567); // "03.5"
String.Format("{0:00.0}", -3.4567); // "-03.5"

Thousand separator

String.Format("{0:0,0.0}", 12345.67); // "12,345.7"
String.Format("{0:0,0}", 12345.67); // "12,346"

String.Format("{0:00%}", 12.3); //12.30%

String.Format("C{0:000000}", 1) //C000001

Wednesday, May 6, 2009

Nested SQL Select Query

SELECT BenefitCd

FROM SOQuoLifeBenifit
WHERE (DependentGrp IN
(SELECT DependentGrp
FROM SOQuoLifeBenifit AS Tmp
WHERE (BenefitCd = 'BASIC')))