Zhanli's tech notes

stuff about SQL Server, Debugging, Windows, Coding and more......

How to detect whether the connection to SQL Server is broken or not

  For managed code, use SqlConnection’s StateChange event:  ...

Date: 01/04/2012

C++ small gotcha - 3

Have two class as below: struct MyBase { __int64 x; __int64 y; MyBase() { memset(this, 0,...

Date: 12/30/2011

C++ small gotcha - 2

What’s wrong with the below code: // a wrapper class which holds memory that’s allocated...

Date: 12/29/2011

C++ small gotcha

Suppose str1 and str2 points to the same zero terminated string, will str1 and str2 be the same...

Date: 05/20/2011

Design pattern in .NET: iterator

The iterator pattern plays very important role in STL. In STL, iterators are the glue between...

Date: 07/19/2010

How to get high resolution timing info

We know that we can use GetTickCount to get timing info but the resolution of this API is limited to...

Date: 07/08/2010

C++ Tips: Adjustor thunk: what is it, why and how it works

When you debug C++ applications, you may notice below unusual functions generated by the compile....

Date: 07/01/2010

C++ tips: Why the pop method of STL stack does not return a value

Or why they don't combine the functionality of pop/top method into one function? We know that the...

Date: 06/28/2010

C++ tips: why you should not leak exception from a destructor

One of the reasons: we know the destructor of an auto object can be called in two situations: 1....

Date: 06/28/2010

Design pattern in .NET: template method

GoF's classical design pattern book has discussed template method pattern: define the skeleton of an...

Date: 06/26/2010

Structured Exception Handling (SEH) and C++ exception handling

C++ exception handling builds on top of the OS SEH support. If you are writing C++ code, it is...

Date: 06/25/2010

C++ tips: Disable "Enable Incremental Linking" linker option to get better symbols

By default, Visual Studio does not generate very friendly symbol names. For example, if you build...

Date: 06/25/2010

C++ tips: AddVectoredExceptionHandler, AddVectoredContinueHandler and SetUnhandledExceptionFilter

I write below code to verify the behaviors of AddVectoredExceptionHandler,...

Date: 06/24/2010