Archive for the ‘tricks’ Category

Log4net integration

January 13, 2017 Leave a comment

Hi folks,
I was integarting log4net library which is amazing for logging in .net Applications.

One issue i run into worth mentioning, I got following error
“log4net:ERROR Failed to find configuration section ‘log4net’ in the application’s .config file. Check your .config file for the and elements. The configuration section should look like: <section name="log4net""

When I used following declartion , issue resolved:

private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);


Categories: C#, Bugs, tricks

Control cholesterol naturally

October 8, 2015 Leave a comment

Food you can include in daily diet to control cholesterol naturally:

• Dark chocolate
• Avocados, avocado oil
• Red wine
• Green Tea
• almonds walnuts pista
• barley, oatmeal
• banana or apple
• fish (bake or grill)
• Olive oil
• soy milk, tofu
• bean, lentils
• pear, apple, oranges, berries
• eggplant, bhindi
• drink 2-3 ltrs of water (warm)


Categories: Food, fun, General, tricks

Store and Reading connection string in web.config

August 14, 2015 Leave a comment

Handy Tips for freshers:
Connection string in .NET 3.5 (and above) config file:
Do not use appsettings in web.config. Instead use the connectionStrings section in web.config.

<add name="myConnectionString" connectionString="server=\SQLEXPRESS;database=myDb;uid=myUser;password=myPass;" />

To read/access the connection string into your code, use the ConfigurationManager class.
string connStr = ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString;

Always store the connection string in a config file.
I saw many freshers save connection string on page(Hard Coding) or in session, Never be among them.

Connection string in .NET 2.0 config file
In the appSettings location, add a key named whatever you like to reference your connection string to.

To read the connection string from code, use the ConfigurationSettings class.
string connStr = ConfigurationSettings.AppSettings("myConnectionString");

Hope this will help few!


Using CSS to Style a RadioButtonList Control in ASP.NET

August 13, 2015 2 comments

I wanted to give styling to Radio list box.
Also wanted to highlight the radio span after selection.
Sharing the code for your reference:

CSS code:
.radioboxlist radioboxlistStyle
padding-right: 20px;
.radioboxlist label {
color: #3E3928;
padding-left: 6px;
padding-right: 16px;
padding-top: 2px;
padding-bottom: 2px;
border: 1px solid #AAAAAA;
white-space: nowrap;
clear: left;
margin-right: 10px;
margin-left: 10px;
.radioboxlist label:hover
color: #CC3300;
background: #D1CFC2;
input:checked + label {
color: #CC3300;
background: #D1CFC2;

In Server code:

<asp:RadioButtonList ID="RadioButtonListGarment" runat="server" CssClass="radioboxlist">

Categories: C#, tricks

SQL SERVER – How To Delete Duplicate Records – Based on Rows

August 11, 2015 Leave a comment

Heree is handy code I got from, for deleting the duplicate records from table.
FROM MyTable
FROM MyTable
GROUP BY DuplicateColumn1, DuplicateColumn2, DuplicateColumn3)

Where DuplicateColumn1,DuplicateColumn2 etc are the columns on which you are checking for duplicate constraints.

Categories: MS Sql, tricks

Cast One List to another List ASP.NET C#

June 10, 2015 Leave a comment

If We need to cast List X to List Y, We can use following syntax:

List listOfY = listOfX.Cast().ToList()

How to find a text inside SQL Server procedures / triggers?

October 8, 2014 Leave a comment

Today I come across an change request at my recent project:
Request was to replace a table reference to new view created in all Procedures and functions.

At first glace, I just annoyed by the change, then mu colleague has suggested a way to search though all Procedures Views and functions,

I got details from

Code for your reference:

DECLARE @Search varchar(255)
SET @Search='TheTableNameYouareSearching'

SELECT DISTINCT AS Object_Name,o.type_desc
FROM sys.sql_modules m
INNER JOIN sys.objects o ON m.object_id=o.object_id
WHERE m.definition Like '%'+@Search+'%'

You will get all listing.Really great…Saved lot of time.