3-Tier Architecture In Asp.net Using C#.

Here we will see how to implement three tier architecture(also known as n-tier architecture) in asp.net application.Three tier architecture is a well known architecture in software development and you can implement it in web based as well desktop applications.

Three tier architecture basically means dividing your project into three layers

1) User Interface Layer [UI] (Also known as Application Layer or Presentation Layer)

2) Business Access Layer [BAL] (Also known as Business Logic Layer)

3) Data Access Layer [DAL]

The advantage of this functionality is it makes a logical separation of components so if in near future we want to replace / change our database we need to change only data layer or if we need to change user interface we need to change only user interface layer and rest remains the same.

Continue reading 3-Tier Architecture In Asp.net Using C#.

Check Username Availability In Asp.net Using Jquery Ajax

Here we will see how to check for username availability using Jquery Ajax method in asp.net. In our website we normally keep the username unique and so it must be checked before saving the record that it has not been taken by any other user. We can do this validation on the submit button click or use OnTextChanged event but it is not so user friendly as the page gets Postback.

Following example demonstrates the same using Jquery Ajax method. Here while creating a user account he can check by making an Ajax call to asp.net [Web Method] at server side to get the availability of the username. It matches the user input against the database records and returns the text based on the availability. You can modified the code as per your requirements:

Continue reading Check Username Availability In Asp.net Using Jquery Ajax

Common Table Expression – Sql Server

Here we will see the basics and implementation of CTE in sql server. A common table expression (CTE) is a temporary result set which will be accessible within the next execution scope of a query. The Common Table Expression was introduced in the SQL Server 2005. It basically defines a temporary view which can be referenced in the same query just as a view. A CTE is similar to a derived table but is not stored as an object and lasts only for the duration of the query. Unlike a derived table, a CTE can be self-referencing and can be referenced multiple times in the same query.

Syntax of CTE is as follows:

WITH CTEName (Column aliases)
AS (Subquery)
SELECT statement
FROM CTEName;

The select statement must be very next to the CTE and the name is mandatory while the argument is optional.
Continue reading Common Table Expression – Sql Server

Pass DataTable To Store Procedure Using Table Value Parameter.

Here we will see how to pass a datatable as parameter to stored procedure in C# using the sql server user defined table type. One of the way to speed up your application is to reduce the trips to your database especially by avoiding a call to stored procedure multiple times.

Table-valued parameters let you pass a collection of table rows as a parameter to your stored procedure. They allow passing entire sets of rows from ADO.Net code to SQL Server.

Below we will see the steps that needs to be followed to implement this functionality.

Continue reading Pass DataTable To Store Procedure Using Table Value Parameter.