Monthly Archives: March 2012

  • Event Handling using Delegates in C#

    Posted on March 27, 2012 by in C#, Dotnet

    Everyone knows about events. We have been using them since VB world. The definition of it has not been changed. If someone has to notify someone about something that happened or something that changed they would do it through events. In event communication, the event sender class does not know which object or method will […]

    Post Tagged with , , ,
  • Identity Columns in SQL Server

    Posted on March 27, 2012 by in Database, SQL Server

    What are identity columns?

    IDENTITY is a property you could set on a table. You could only set this property on one column in the entire table. SQL Server will take care of incrementing this column based on the seed you gave while creating the property.

    IDENTITY [ ( seed , increment ) ]

    Seed — Is the value that is used for the very first row loaded into the table.

    Increment — Is the incremental value that is added to the identity value of the previous row that was loaded.

    Default values – (1,1)

    Limitations :

    1. An Identity column is not guaranteed to be unique nor consecutive.

    2. If any insert failure is there then also it can change the current seed value.

    3. If we truncate a table (but not delete), it will update the current seed to the original seed value.

    Post Tagged with ,
  • Anonymous Methods using Delegates in C#

    Posted on March 27, 2012 by in C#, Dotnet

    “Delegates in C#”. Anonymous methods were introduced in C# 2.0 to support passing code as parameters to delegate. Anonymous methods enable you to omit the parameter list. This means that an anonymous method can be converted to delegates with a variety of signatures. Anonymous methods allow us to define a code block where a delegate object is acceptable. This facility saves us an extra step of creating a delegate for small code blocks that we want to pass to a delegate. It also removes the cluttering of small methods in the class code.

    When to use anonymous methods?

    For example, specifying a code block in the place of a delegate can be useful in a situation when having to create a method might seem an unnecessary overhead. A good example would be when launching a new thread. This class creates a thread and also contains the code that the thread executes, without the need for creating an additional method for the delegate.

    Post Tagged with , ,
  • Delegates in C#

    Posted on March 27, 2012 by in C#, Dotnet

    A delegate is similar to a function pointer in C or C++ but they are typesafe. Using a delegate allows the programmer to encapsulate a reference to a method inside a delegate object. The delegate object can then be passed to code which can call the referenced method, without having to know at compile time which method will be invoked.

    When to use a delegate?

    An event design pattern is used.
    It is desirable to encapsulate a static method.
    The caller has no need access other properties, methods, or interfaces on the object implementing the method.
    Easy composition is desired.
    A class may need more than one implementation of the method.

    Post Tagged with ,
  • Nested MSI (Concurrent Installations):

    Posted on March 26, 2012 by in Application Packaging

    Nested MSI (Concurrent Installations):
    Nested Installation is calling an Child.msi from Parent.msi.
    Concurrent Installations is a deprecated feature of the Windows Installer. Applications installed with concurrent installations can eventually fail because they are difficult for customers to service correctly. Do not use concurrent installations to install products that are intended to be released to the public. Concurrent installations can have limited applicability in controlled corporate environments when used to install applications that are not intended for public release.

  • How to make Extracted MSI work:

    Posted on March 26, 2012 by in Application Packaging

    In our earlier post we explained how to extract an MSI from the Setup.exe. The MSI is normally extracted to the %temp% directory.
    In some applications when you try to run these MSI’s that are extracted they will throw the following error message “This application cannot be installed. Please run the application from SETUP.EXE

  • How to do asynchronous processing using delegates in C# & WPF

    Posted on March 23, 2012 by in C#, Dotnet, WPF

    We all know what delegates are. I am not going to bore you with what. If you are really interested in finding out, you could read my other blog “Delegates in C#”. When we do process heavy tasks we don’t want the user to wait and he does not want to wait. All he would […]

    Post Tagged with ,
  • Exception Handling in SQL Server

    Posted on March 22, 2012 by in Database, SQL Server

    SQL Server 2005 has introduced TRY / CATCH block which made error handling easy. The construct is similar to error-handling concepts in languages like C#. If an error occurs in the TRY block, or in a stored procedure called by the TRY block, execution is transferred to the CATCH block.  Error Handling Functions  In the […]

    Post Tagged with
  • How to use Cursors in SQL Server

    Posted on March 22, 2012 by in Database, SQL Server

    If you want to process each row at a time, Cursors is your best bet. You could perform complex operations of row by row sequentially. Imagine cursor as a pointer in C++ pointing to a row in a result set. To summarize the whole process, you could say using cursors involves these simple four steps […]

    Post Tagged with
  • How to automate excel in C# ?

    Posted on March 22, 2012 by in C#, Dotnet

    In this article I would tell you how to manipulate excel using Microsoft interoperability. I would laying out code for performing different actions such as 1)      Opening & Closing of excel application 2)      Adding,  opening & closing of excel sheets 3)      Adding,  opening & closing of excel work books 4)      Setting attributes and text to […]

    Post Tagged with