Archive for February, 2012

Checking State of Connection Object in ADO.NET

While using ADO.NET, most of the developers open a connection with the data source and start using that connection object. But, what if connection is not opened or is in broken state? Well, in that case, we’ll come across runtime exception. And, this is where most of developers make a mistake. So, what to do? Answer is we need to check the connection state before using it.

The ADO.NET Connection object has got six connection states:

  1. Open: The connection is open.
  2. Closed: The connection is closed.
  3. Connecting: The connection object is connecting to the data source.
  4. Fetching: The connection object is pulling out data from the data source.
  5. Executing: The connection object is executing a query i.e. command.
  6. Broken: The connection is broken. This happens only after connection to the data source has been opened earlier. Most likely connection would be closed in this state.

Here is an example how to use it.

Upcoming Microsoft SQL Server 2012 Books by Wrox

 Wow! Much awaited books on SQL Server 2012 by Wrox publication on the way… 


Beginning Microsoft SQL Server 2012 Programming

by Paul Atkinson, Robert Vieira




Professional Microsoft SQL Server 2012 Administration

Adam Jorgensen, Steven Wort, Ross LoForte, Patrick LeBlanc, Brian Knight




Professional Microsoft SQL Server 2012 Reporting Services

Paul Turley, Robert M. Bruckner, Thiago Silva, Ken Withee, Grant Paisley




Professional Microsoft SQL Server 2012 Analysis Services with MDX

Sivakumar Harinath, Ronald Pihlgren, Denny Guang-Yeu Lee, John Sirmon, Robert M. Bruckner




Professional Microsoft SQL Server 2012 Integration Services

Brian Knight, Erik Veerman, Jessica M. Moss, Mike Davis, Chris Rock




Keep an eye on bookshelf for them. I think papercopy will hit Indian market by June – Aug 2012…


02 – .NET Training at ABB, Bangalore from Jan 16 – Jan 18, 2012

.NET Training at ABB, Bangalore from Jan 16 – Jan 18, 2012.

01 – .NET Training at L&T Infotech, Bangalore from Oct 22 – Nov 11, 2011

.NET Training Campus-to-Corporate batch for 27 participants at L&T Infotech, Bangalore from Oct 22, 2011 to Nov 11, 2012.


03 – .NET Training at L&T Infotech, Bangalore from Jan 20 – Feb 7 2012

Today, I finished .NET training for 22 participants at L&T Infotech, Bangalore. I always enjoy when I train Campus-to-Corporate batches like this one. I see so much enthusiasm and energy in these guys, which reminds me of initial days of my career. I really enjoy this kind of workshop…

Have a look at batch photo…