Tuesday, 21 January 2014

Introduction of C#

                                                                                                                                      Previous....... 
                                                                                                                                                    Next.......

C# is case sensitive language.
In this Part

1. We will learn the basic structure of a c# program. The program we used in this video is shown below.


// Namespace Declaration
using System;
class NetQube
{
    public static void Main()
    {
        // Write to console
        Console.WriteLine ("Welcome to NetQube Technologies!"); 
    }
}

2. Understand the purpose of using System declaration - The namespace declaration,using System, indicates that you are using the System namespace. If  you omit theusing System, declaration, then you have to use the fully qualified name of the Consoleclass. A namespace is used to organize your code and is collection of classes, interfaces, structs, enums and delegates. We will discuss about namespaces in detail in a later session.
3. Purpose of Main() method - Main method is the entry point into your application.


                                                                                                                                       Previous....... 
                                                                                                                                                    Next.......



Dot Net Tutorial

Here i will explain all the tutorial as a chapter. I will explain from basic to end with examples and i will give practical Knowledge.

Previously I have explained about SQL SERVER, Asp.Net, Ado.Net .
Here i will explain for those  I have created this tutorial to help those in need.If you find this useful then please share it with your friends on Facebook and Google plus. 
If anyone face problem regarding these tutorial then leave a comment.


  1. C#
  2. Asp.net
  3. Ado.net
  4. SQL Server
  5. Windows Form
  6. EntityFrameWork Tutorial
  7. Asp.Net MVC Tutorials
  8. GridView Tutorials
  9. Angular JS Tutorials

Friday, 17 January 2014

What is deferred name resolution in SQL Server


Let me explain deferred name resolution with an example. Consider the stored procedure shown below.

Create procedure spGetCustomers
as
Begin
Select * from Customers1
End

Customers1 table does not exist. When you execute the above SQL code, the stored procedure spGetCustomers will be successfully created without errors. But when you try to call or execute the stored procedure using Execute spGetCustomers, you will get a run time error stating Invalid object name 'Customers1'.

So, at the time of creating stored procedures, only the syntax of the sql code is checked. The objects used in the stored procedure are not checked for their existence. Only when we try to run the procedure, the existence of the objects is checked. So, the process of postponing, the checking of physical existence of the objects until runtime, is called as deffered name resolution in SQL server.

Functions in sql server does not support deferred name resolution. If you try to create an inline table valued function as shown below, we get an error stating Invalid object name 'Customers1' at the time of creation of the function itself.

Create function fnGetCustomers()
returns table
as
return Select * from Customers1

So, this proves that, stored procedures support deferred name resolution, where as functions does not. Infact, this is one of the major difference between functions and stored procedures in sql server.

Stored Procedure


Write a Stored Procedure that takes column name as a parameter and returns the result sorted by the column that is passed
Let's understand the requirement better with an example. I have an Employee table as shown below. 



I want a stored procedure that returns employee data sorted by a column, that the user is going to pass into the stored procedure as a parameter. There are 2 ways of doing this.

Option 1: Use Case Statement as shown below:
Create Proc spGetEmployeesSorted
@SortCoumn nvarchar(10)
as
Begin

Select [Id],[Name],[Gender],[Salary],[City] 
From   [Employee]
Order by Case When @SortCoumn = 'Id' Then Id End,
                Case When @SortCoumn = 'Name' Then Name End,
                Case When @SortCoumn = 'Gender' Then Gender End,
                Case When @SortCoumn = 'Salary' Then Salary End,
                Case When @SortCoumn = 'City' Then City End
End


Option 2: Use Dynamic SQL as shown below:
Create Proc spGetEmployeesSortedUsingDynamicSQL
@SortCoumn nvarchar(10)
as
Begin

Declare @DynamicQuery nvarchar(100)
Set @DynamicQuery = 'select [Id],[Name],[Gender],[Salary],[City] from [Employee] order by ' + @SortCoumn
Execute(@DynamicQuery)

End

C# program Selection Sorting

Selection sort is a straightforward sorting algorithm. This algorithm search for the smallest number in the elements array and then swap i...