Saturday, December 22, 2007

SQL Performance Tips

When you are writing serious SQL, TSQL or PLSQL one of the common error that you play around is the "Time Out" errors. There are number of reasons for these errors. You have to exactly pin point the problem to properly fix it. I thought of publishing some links that I found on this area which might helpful for you
The areas which you have to look for are :
1) Transaction Locking
2) Performance of your queries (In medium and high data volumes)
3) Transaction isolation levels
4) Clustered index and indexes of your tables
Browse the flowing for in-depth understanding.....

DBA’s Quick Guide to Timeouts
How to troubleshoot ODBC timeout errors

Friday, November 30, 2007

Dynamic SQL Tips and Tricks

Definitely you will be facing lot of challenges in your day to day SQL programming. I found the following site very use full to find curse and blessings of dynamic SQL. Have a look, it might be useful for for you as well


The Curse and Blessings of Dynamic SQL

Tuesday, June 12, 2007

ASP.NET Ajax support in DNN

DotnetNuke developers good news! Partial rendering (ASP.NET Ajax support) is now available for module controls with DNN 4.5. Shaun Walker has published a good blog post. This is a good initiative and definitely .NET community will love this.

Saturday, June 09, 2007

Architects! Design Scalable ASP.NET Solutions

Do you have these issues ?
  • My solution accesses web services and they are fairly slow
  • Overall site usage is very high
  • Simple web requests takes too long to get their responses
The reason for the above issues are the solution is not scaling enough to handle heavy work loads. If you are using web services in your solution the site can easily get bogged down when there is a heavy load accessing the site. The reason for this is the entire ASP.NET thread pool will get busy due to slow web service calls and then all the subsequent requests starts queueing up until threads gets free-ed up. The reason is solution is not scaling in heavy work loads.

One of the simplest design technique is to design asynchronous pages which access third party web services. ASP.NET 2.0 has built in support for implementing Async web pages. You simply have to :

1) Add <%@ Page Async="true" directive in your page
2) Register "Begin event handler" and "End event handler" delegates using AddOnPreRenderCompleteAsync method

Call your web service in Begin event handler and process the web service response in End event handler. Read this for in-depth understanding.

Sunday, June 03, 2007

My Last Trip at EC



This was my last trip at Eurocenter and was a remarkable one. The place was beautiful and we enjoyed a lot at this cool atmosphere. EC guys were great and I will miss these great fun events yet to come..............

Saturday, May 26, 2007

ASP.NET 2.0 Beginners Troubleshooting Guide

Problem: I'm using ASP.NET 2.0's membership provider for forms authentication. It is working fine in VS environment with the integrated web server. But when I move it to IIS, login control fails to authenticate the same user.

Resolution : In IIS the account(ASPNET or NETWORK SERVICE) access the app_data folder. Therefore the app_data folder must have write/modify permission for this account

I will try to add some troubleshooting tips into this article time to time.

Sunday, May 20, 2007

Do you believe in Unit Testing

Most of the developers don't believe in unit testing. As for my experience I don't really blame for developers. Why they are not attempting is b'cos product/project release time pressures. Many software houses have not embraced unit testing into their process therefore the time component of unit testing is not included in the estimation. But that's only an one aspect of it the other side is lack of knowledge and training on proper unit testing tools and practices. If you are planing to implement unit testing process for your team have a look the flowing tools. They are very useful to implement the unit testing process properly. One of the good book in this topic is Art Of Unit Testing by Roy Osherove".

Here is how one of Microsoft MVP's described this book

“Beautifully craft ed, detailed unit testing masterpiece.
Bravo, Bravo, Bravo!”
—Mohammad Azam, Microsoft MVP, HighOnCoding

Some of the supplementary tools are :

- NDbUnit, DbUnit
- Rhino Mocks, NMock
- Fit, WinFITRunnerLite
- TypeMock
- NUnitAsp

Enjoy and Rethink about unit testing.....

Wednesday, May 16, 2007

.NET Tools Portal

Sometimes it's difficult to find the correct tool at the correct time. I found this portal for .NET tools a common place to some valuable tools. It has categorized the tools nicely and easy to find. Here is the site

Saturday, May 05, 2007

Maintainable Regular Expressions

We all know regular expression is a very powerful tool. But one of the difficulties we face is reading regex statements written by others. Sometimes it's almost impossible. So it's always better to document your regular expressions and make them more readable for others and make your piece of code more maintainable. Here what you can do

Regex regex = new Regex(@"
^ # anchor at the start
(?=.*\d) # must contain at least one numeric character
(?=.*[a-z]) # must contain one lowercase character
(?=.*[A-Z]) # must contain one uppercase character
.{8,10} # From 8 to 10 characters in length
\s # allows a space
$ # anchor at the end",
RegexOptions.IgnorePatternWhitespace);

You can comment your expressions using # but make sure you use the RegexOption IgnorePatternWhitespace.

Saturday, April 21, 2007

How to Study with your Spouse, Children and a Full Time Job

You may be wondering this is impossible. 50% of my colleagues don't believe in this and they destroy their careers after they got married and have started on their kids. Read this article this is a good one to keep you energize and to move up with your career. Though you have not done your degree or professional certifications you will be up-to-date in your industry by following this and count on me you will be in a good position in your work place :)))

How to Study with Full Time Job

Sunday, April 08, 2007

CSS Friendly Adaptor Controls

Our web designers are always complain about the code generated from ASP.NET controls. For an example code generated from Menu controls are using table tags. But modern web designers love CSS based menus b'cos of two reasons. They looks elegant and the page size is very small compared to table base menus. So here is what you are looking for...... CSS Friendly Adaptor Controls, brilliant piece of work. You can make your existing site produce CSS friendly code and style your controls using CSS without even touching your existing aspx pages. It's definitely a wow isn't it :) Actually it is.... Compare the following rendered html using adaptor control with your own table base menu rendering results you will feel the difference.

<div class="SimpleEntertainmentMenu" id="Menu1">
<div class="AspNet-Menu-Horizontal">
<ul class="AspNet-Menu">
<li class="AspNet-Menu-WithChildren">
<a href="javascript:__doPostBack('Menu1','bMusic')" class="AspNet-Menu-Link">
Music</a>

<ul>
<li class="AspNet-Menu-Leaf">
<a href="javascript:__doPostBack('Menu1','bMusic\\Clasical')" class="AspNet-Menu-Link">
Clasical</a>
</li>
</ul>
</li>
<li class="AspNet-Menu-WithChildren">

<a href="javascript:__doPostBack('Menu1','bMovies')" class="AspNet-Menu-Link">
Movies</a>
<ul>
<li class="AspNet-Menu-Leaf">
<a href="javascript:__doPostBack('Menu1','bMovies\\Action')" class="AspNet-Menu-Link">
Action</a>
</li>
</ul>

</li>
</ul>

</div>
</div>


In the App_Browsers folder create the CSSFriendlyAdapters.browser and configure all the adaptor controls to be used with different ASP.NET controls.
In this file you can configure in which browsers Adaptor controls should be enabled or disables. Please refer CSS Friendly Adaptors for more details

Sunday, April 01, 2007

MS SQLEXPRESS Issue

If somebody is getting the following error when trying to create new sqlexpress data bases from Visual Studio please follow the instructions bellow to sort out the problem. I've been struggling for couple of hours to figure out the problem

Error : "Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance"

Resolution : Delete C:\Documents and Settings\USERNAME\Local Settings\Application Data\Microsoft\Microsoft SQL Server Data\SQLEXPRESS.

This is definitely authentication problem. When you uninstall and reinstall sqlexpress it can happen.

Sunday, March 25, 2007

Automate your Build and Packaging Process

Check this out great toolset for automate your build and packaging process

Wix ToolSet
Tips and Tricks
Learn MSBUILD

Thursday, March 22, 2007

Beauty Of .NET (Extender Controls)

Have you ever wanted to extend functionality of .NET controls ? if so first thing you will do is subclasing the control and implement your functionality. Hmm there is a much more elegant way of doing this by using Extender Controls.

Extender controls allows you to extend functionality of exiting controls in a form without subclasing. You have to only drag the extender control to the form and there you go ..... all the controls in the form are equipped with the new functionality.

The basics are very simple, and you have to build the rest according to your needs. End of this article I have presented some interesting things that can be done using this technique. Extender control is a component so you have inherit your class from a component and implement the IExtenderProvider interface.

[ProvideProperty("HelloWorld",typeof(System.ComponentModel.Component))]
public class HelloWorldComponent : Component,IExtenderProvider

IExtenderProvider interface is very simple. You have to only implement the CanExtend method.

public bool CanExtend(object extendee)
{
if (extendee is Control && !(extendee is HelloWorldComponent))
{
return true;
}
else
{
return false;
}
}

The above will extend all the controls in a form (win or web) with properties extended from extender control. You can introduce one to many properties to controls in a form using one extender control. For introduce a property you have implement two methods Set(Component,String) and Get(Component). ProvideProperty attribute gives names of the properties. Pls refer Extender Controls Tutorial for more details on creating and using extender controls.


Interesting things you can do with Extender Controls

1) UI Security Implementations
2) Two Way Data Binding in ASP.NET for simple controls like text boxes and radio buttons

Have fun.........

Friday, March 09, 2007

Robust Coding with CBO's and Hydrator

I thought of giving some of my thoughts on DAL and BL designing. Some buzz words today among designers are DTO's and Business Objects (BO's). DTO Vs BO discussion is somewhat controversy and I'm not going to touch that here :). DTO's are smiler to CBO's (Custom Business Objects) that I'm talking in this article.

First I'll refer to a Framework that use CBO's and hydrator design pattern. DotnetNuke is a open source Content Management and Portal development framework (http://www.dotnetnuke.com/). It has a large community and fairly stable product. We have used this for couple of commercial products and customers are happy so do we. The complete data layer of this solution is built on CBO's and a Hydrator. This greatly reduces the size of the code and it's complexity.

If you are using CBO's in your code just think how are you going to populate those objects using a DaraReader. If you are going to hand code all the filling mechanisms definitely it's going to be a nightmare. Just think the the maintenance effort, if you change something in the data model you have to go and change the filling codes as well. You can greatly reduce this complexity by using a hydrator or a helper class with CBO's to automatically fill your CBO's based on reflection.

Few hints on how to write a flexible helper class (Hydrator)

  • Use .NET 2.0 Generics to define the FillCollection method

public static C FillCollection(Type objType, IDataReader dr)
where T : class, new()
where C : ICollection, new()

By using generics you can generalize the method to use custom return collections as well as to define concrete objects to be filled at compile time. What I love about this is you can specify generic constraint using where clause.

C# supports five different constraints:


  1. Interface constraint - The type argument must implement the specified interface.
  2. Inheritance constraint - The type argument must derive from the specified base class.
  3. Class constraint - The type argument must be a reference type.
  4. Struct constraint - The type argument must be a value type.
  5. New constraint - The type argument must expose a public, parameterless (default) constructor.

In the above
"where T : class, new()" means the object should be a reference type and it should have a parameterless constructor


  • Use Custom Attributes to map object properties to DB columns and to define custom values to null properties. So you don't have to use the same DB column names in your object properties and you can override default null values.
Download Code

Saturday, February 24, 2007

Google Apps

My friend Hasith one day showed me this interesting concept of google docs. Though I was not that interested on it, Today i thought of just looking at it. I came across this online Google Application concept it's not just Google docs, it has different application packages for home users, small business users, enterprise users etc. It's interesting concept ah! Everything is 100% free :) only requirement is you have to have a domain name to get registered into Google apps. Before I was using MS word to write my blog posts today I'm using Google Docs Wow. The great benefit I'm getting is I can write my documents if I can get hold of a computer and Internet connection. I don't have to wait till I come home or to the office. This is a hassle free powerful communication & collaborative platform for all of us enjoy!

Tuesday, January 09, 2007

Connection Strings

Guys who want's to refer connection strings here is the site http://www.connectionstrings.com/

Thursday, January 04, 2007

.NET Documentation Compilers

When Microsoft introduces XML documentation I was wondering why Microsoft didn’t introduce a compiler to compile this XML documentation into nice looking API’s. Hmm I don’t have an answer for it but some open source guys came up with a good tool (NDOC) for this need. Guys who have the experience in NDOC know what I’m talking about. If you don’t know about NDOC have a look at http://sourceforge.net/projects/ndoc/

Now the good news is Microsoft have open up there internal MSDN style XML documentation tool to the community. All who are interested in code / API documentation look at SandCastle. http://blogs.msdn.com/sandcastle/ is a good place to hang around. Download it from http://www.microsoft.com/downloads

SandCastle is purely command prompt base set of tools and compilers. If you like to get a technical overview of the tool have a look at this blog

https://blogs.msdn.com/sandcastle/archive/2006/07/28/681209.aspx

Some guys have written a NDOC style application in top of SandCastle tools and can be found at http://www.codeplex.com/SHFB

Enjoy !