Wednesday, July 14, 2010

SSRS, Cascading Parameters and Expression

-- dropdown filter
http://msdn.microsoft.com/en-us/library/aa337169.aspx

--expression
http://msdn.microsoft.com/en-us/library/ms157328.aspx

Tuesday, July 13, 2010

UNIX, crontab file

-- Basic UNIX script command
http://freeengineer.org/learnUNIXin10minutes.html

--list Crontab file

crontab -l

--edit crontab file

crontab -e

--Get yesterday using UNIX script
today=`date "+%Y%m%d"`
#get yesterday
date "+%Y%m%d"
date +%Y%m%d -d "yesterday"

CurrentDate=`TZ="GMT+24" date +'%y%m%d'`
echo $CurrentDate;

YESTERDAY=$((`date +%d` -1))
MONTH=`date +%m`
YEAR=`date +%Y`
NDAY=`date +%u`
WEEKDAY=${DAYS[`date +%u`]}
if [ $YESTERDAY -eq "0" ]
then
MONTH=$((MONTH-1))
if [ $MONTH -eq "0" ]
then
MONTH=12
YEAR=$((YEAR-1))
fi
set `cal $MONTH $YEAR`
shift $(($# - 1))
YESTERDAY=$1
fi
echo $YEAR$MONTH$YESTERDAY;
varyesterday="$YEAR$MONTH$YESTERDAY"
#end yesterday

echo $varyesterday;

Tuesday, June 22, 2010

String must be exactly one character long.

When you have DBML lINQ entity fields with CHAR data type. you will get an error while retrieve the data.

Solution:
----------
1) go to the DBML entity
2) select field
3) press F4
4) change data type to string from char, where you have DB data type VARCHAR(1)
5) Save

Wednesday, May 26, 2010

Cannot add an entity with a key that is already in use, LINQ

When you have table with ID coulumn (uniqueidentifier) and default value = (newid()),
than the above error occur.

To Resolve:

1) go to your .DBML file design view
2) go to property of particular columns
3) set "Auto generated Value" = true.

it will add following in DBML file IsDbGenerated="true"

Friday, May 14, 2010

Power shell, installutil

Error occur while installing powershell dll.

System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information

Resolution:
make sure you have all the project reference dll in the project, developer always forgot reference dll while delpoying the project.

alternate approch is to load the reference DLL into GAC

String or Binary Data Would Be Truncated Error, LINQ

Error: String or Binary Data Would Be Truncated.

Desc:
Generally this error occurs when we are trying to inser/update large value in SQL server table that are not fit into columns lenght of table.

In one scenario i experienced the following scenario:

I had the one enum like below:
public enum MyEnum
{ First = 101, Second=102, Sixth=103)

now I was using this enum like MyEnum.First and assigning to the one variable
But when i was trying to insert that entity in database using LINQ i was getting the above error:


After doing debugging, I've to do following changes

var myvar = (int) MyEnum.First;

The above statement will return the 101,

that's it for now.

object reference not set to an instance of an object C#

Error: object reference not set to an instance of an object

C# developer usually getting the above error, I'd suggeste first check where you are using Trim(), Substring(), Length(), ToUpper(), ToLower() function with string variables in your codind.

To Resolve:
if(!String.IsNullOrEmpty(userFirstName))
{

-- your userFirstName assignment code here
}