Monday, January 30, 2012

Getting Class Name and Method name using reflection

To get the current method and class name in which the code is executing, we can use reflection.

Method Details

System.Reflection.MethodBase.GetCurrentMethod().Name, 

Class Details
System.Reflection.MethodBase.GetCurrentMethod().ReflectedType.Name

Handy to log the errors .. 

Thursday, January 26, 2012

Error :Attempted to access an unloaded appdomain

Attempted to access an unloaded appdomain. (Exception from HRESULT: 0x80131014)

This occurs when we try to open two different connections in the same  Transaction Scope . Use Transaction Scope.Suppress for one of the connection if you are not performing any transaction in one of the connection.


But if you are making transactions in both of the connections as a single one ... i need to study further about this ... probably you have to open a new transaction under the main one .. will verify later 

Dynamic Grouping in SSRS

To achieve dynamic grouping in SSRS , i.e you group by a parameter chosen by the user.

1) Send the group by parameter to the stored procedure/sql statement and let SQL handle the grouping by case statement
 Ex :
    SELECT   case(@groupby)
when 'gender' then dummy.Gender
when 'race' then dummy.Race
when 'district' then dummy.District
end "groupbyfield",
count(*)"Count",
 FROM  dbo.dummy
WHERE DummyDate BETWEEN @startdate and @enddate
     GROUP BYcase(@groupby)
when 'gender' then dummy.Gender
when 'race' then dummy.Race
when 'district' then dummy.District
end "groupbyfield"

2) Sort by the "groupbyfield"  in SSRS.