Compare two tables record (SQL Server)

By Ashish Khandelwal, July 15, 2011

Sometime we want to compare the records between two database tables. These databases could be on same server or on different servers. Here is some information about how we can compare records between two tables. Hope this will help and give you some information.

The ‘EXCEPT’ operator performs the compare between two tables:

When both databases are on same server:

The following query returns any distinct values from the query to the left of the EXCEPT operand that are not also found on the right query.

SELECT ProductID

FROM Production.Product

EXCEPT

SELECT ProductID

FROM Production.WorkOrder ;

–Result: 266 Rows (products without work orders)

Read more »

IBM WebSphere MQ security methods

By Ashish Khandelwal, July 10, 2011

In WebSphere MQ, there are three methods of providing security:

  1. The Object Authority Manager (OAM)
  2. User-written, or third party, channel exists
  3. Channel security using Secure Sockets Layer (SSL)

The Object Authority Manager (OAM): This is automatically installed and enabled for each queue manager you create, unless you specify otherwise. All actions performed by an application connected to a queue manager are authenticated by the queue manager by a component called OAM. Every time an application attempts any action against a WebSphere MQ object, the OAM ensures that the identity under which that application is connected to QM has been set to allow the type of access it is requesting on the object. Read more »

Velocity Usages and advantages

By Ashish Khandelwal, July 8, 2011

Velocity provides highly scalable distributed caching environment for Microsoft .net framework. By using Velocity, frequently used data can be stored in distributed cached environment for faster access and to avoid unnecessary calls to the database. Velocity also supports locking as well as automatic load balancing.

Velocity can be used for windows application or web application.

Velocity is provided in the form of a cluster. In this section I will cover what are all useful elements, how cluster works and some programming with velocity. Read more »

Searching for Multiple Strings

By Ashish Khandelwal, July 5, 2011

Suppose you have an application that needs to search for all occurrences of multiple strings in a text stream. For example, you might want to search a large text file for all occurrences of “cycling”, “bicycling”, “bicycle”, “cycle”, “bike”, and other bicycling-related terms. This can be a more difficult task than it first appears.

The simple case

If the file is small, the task isn’t terribly difficult. You can read the entire file as a string into memory and then use standard string searching methods to find each string, as shown here.

private static void FindAllSimple(string textToSearch, string[] searchStrings)
{
    // brute force method
    foreach (var s in searchStrings)
    {
        int iPos = 0;
        int foundPos;
        while (iPos < textToSearch.Length && (foundPos = textToSearch.IndexOf(s, iPos)) != -1)
        {
            Console.WriteLine(“{0},{1}”, foundPos, s);
            iPos = foundPos + 1;
        }
    }

  Read more »

All about Multithreading (Concept, Issues and Synchronization)

By Ashish Khandelwal, June 30, 2011

Multithreading ensures that the program never “goes to sleep” by keeping UI more responsive to the user. In my blog I cover numbers of articles on multithreading programming, issues with multithreaded programming and the synchronization technique to handle these issues. I found it is worth to consolidate these all information at one place. Hopefully this will help visitor to quickly refer the topic.

What is Multithreading?

Article: Multithreading Read more »

Issues with Multithreaded Programming: Part 3

By Ashish Khandelwal, June 23, 2011

In my previous articles “Issues with Multithreaded Programming: Part 1” and “Issues with Multithreaded Programming: Part 2” I have explained about four issues of Multithreading programming 1) Race Condition 2) DeadLock 3) LiveLock and 4) Priority Inversion. Continuing to my previous articles, in this article I have explained about following issues:

Issues with Multithreaded Programming: Part 2

By Ashish Khandelwal, June 22, 2011

In my previous article Issues with Multithreaded Programming : Part 1 I have explained about two most common issues of Multithreading programming 1) Race Condition and 2) DeadLock. Continuing to my previous article, in this article I have explained about following issues:

Issues with Multithreaded Programming: Part 1

By Ashish Khandelwal, June 21, 2011

Multithreaded (Parallel) programming is difficult for many reasons. Developer always has to put extra care to protect the program from issues like race condition, deadlocks, livelocks, priority inversions, two-step dances, and lock convoys. My personal experience says these all issues are tough to identify and then resolve.

It is always better to have understanding on these issues before writing multithreaded application. In this article I have covered the quick overview of following issues associated with multithreaded programming:

  • Race condition
  • DeadLock
  • LiveLock
  • Priority Inversion
  • Two-Step Dances
  • Lock Convoys Read more »

Lambda Expressions supersede Anonymous Methods

By Ashish Khandelwal, June 20, 2011

Lambda expressions introduced in the C# 3.0. Lambda expressions help reducing the burden of writing Anonymous Methods. Before Anonymous Methods there was only way to declare the delegate was to use named method. Microsoft has put continues effort to reach to Lambda expressions:

-      Before C# 2.0, named methods was the only option to declare the delegate

-      C# 2.0 introduced the Anonymous methods.

-      C# 3.0 and later, lambda expressions supersede anonymous methods as the preferred way to write inline code. There is only one case in which an anonymous method provides functionality not found in lambda expressions. 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. This is not possible with lambda expressions. Read more »

Create Database from Entity Model

By Ashish Khandelwal, June 14, 2011
In my last article LINQ to SQL Vs Entity Framework I discussed about how powerful the ADO.Net Entity Framework compare to LINQ2SQL. In this article I will discuss about how to create Database from Entity Model (Entity Framework).
While designing Database for a project, we normally first finalize the models (entities and the relationships) and then create the physical database in the database server. Entity Framework allows us to follow the same approach where we can create entities, build the relationship between entities, finalize the design of database and could also start coding using entities even if physically database is not exist. Once we are done with database modeling, we can create physical database from Model. So far, one item is missing from entity framework which is data, we still need database server to store the data. Hopefully Microsoft will come with something to provide kind of temporary storage where no database server is required for atleast for debugging purpose. Read more »

LINQ to SQL Vs Entity Framework

By Ashish Khandelwal, June 8, 2011

LINQ to SQL and Entity Framework both are designed for ORM (Object Relational Model) support. They are developed to avoid the difficulties involved in writing Object Oriented code to perform RDMS operations. The OOP and RDMS are conceptually very different. The question arises when to use LINQ2SQL and when to use Entity Framework. What is the different between LINQ to SQL and Entity Framework.

LINQ to SQL and the Entity Framework have a lot in common, but each has features targeting different scenarios. While speaking about similarities or differences, I understand that ADO.NET Entity Framework’s LINQ to Entities can be considered as superset of LINQ to SQL and that, ADO.NET Entity Framework is much more than LINQ to Entities. Read more »

Hyperlink in ListBox

By Ashish Khandelwal, June 3, 2011

Today, one of my friends was asking me a question about how to add hyperlink text into the ListBox. I replied by adding respective control directly to the ListBox. Here in reply to my friend question, I am describing the steps:

Every Control in C#.net has a property called “Contorls” to add any control within it. I used the same to add LinkLable (Hyperlink text) to add into ListBox.

I have created one simple Windows Form application called “HyperLinkInListBox”. Added one windows form called “frmHyperLinkInListBox” and the following controls within the form:

  1. One ListBox control named “lstName” : this will display all the Names and will have hyperlink associated with it.
  2. One Label control “lblURL” : This will the URL associated with Name. So that when user will click on any Name in the ListBox, the respective URL will display here. Read more »

Distributed Caching

By Ashish Khandelwal, June 2, 2011

One of the key techniques used to develop high-performance and scalable application is Distributed Caching.

In this article I will cover:

-          What is Distributed Caching and

-          What is the need of Distributed Caching

Caching is a well-known concept; it is a technique to store the data in-memory so that application is not required to fire a query over the network to communicate with database or service. Communicating over the network always add lots of additional overheads (parsing, validating etc.) – ultimately increase the overall processing time for the request. When using caching, the data is always available in ready to use format within the memory, so that the overhead of network response time and processing time for the request can be reduced – ultimately increase the performance. Read more »

Socket programming vs. WCF

By Ashish Khandelwal, May 31, 2011

A very simple scenario where client sends a request to server to perform certain action. There is no much data transfer between two parties – Probably no more than 50 bytes. We need to decide whether we go with Socket programming or use WCF (request-reply messaging pattern).

The analysis says: Read more »

Quick and short: Database Indexes

By Ashish Khandelwal, May 31, 2011

This article is written under ‘Quick and Short’ edition. In this article I will explain about database indexes, type of indexes, best practices to use index, how to use indexes to improve performance of T-SQL (database query).

Read more Quick and Short articles.

What is index

Indexes in databases are very similar to indexes in libraries. Indexes allow locating information within a database fast, much like they do in libraries. If all books in a library are indexed alphabetically then you don’t need to browse the whole library to find particular book. Instead you’ll simply get the first letter from the book title and you’ll find this letter’s section in the library starting your search from there, which will narrow down your search significantly.

An Index can be created on a single column or a combination of columns in a database table. A table index is a database structure that arranges the values of one or more columns in a database table in specific order. The table index has pointers to the values stored in specified column or combination of columns of the table. These pointers are ordered depending on the sort order specified in the index. Read more »