Monday, 2 April 2018

Learn Angularjs step by step ( Training video)

Sunday, 1 April 2018

Group function and aggregate function

Group function and aggregate function

SQL group function or aggregate function retuns single value from the group.
These are built in function in sql and oracle

Aggegate function.
Min – This function is used to get the mimimum value from the specified column
Max- This function is used to get the maximum value from the specified column
Sum- This function is used to get the sum if numeric column
Count- This function is used to get the actual number of values (count)  from the  column
Avg- this function used to get the average value from the column.

Group function
Distinct
The distinct () function is used to get the disctinct record from the column.


select distinct(TitleOfCourtesy) from Employees

Inheritance Code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplicationSecondTry
{
    class Program
    {
        static void Main(string[] args)
        {
            /*
             * We have two classes A and B.
             * Class B inherits class B.
             * if we create object of class A ( Which points to the class A  // A O = new A(); // ) then
             * We can call and access the base class (Class A) Methods and data members
             */
            A O = new A();
            O.Method_In_A();
            O.a = 20;

            /*
             * We have two classes A and B.
             * Class B inherits class B.
             * if we create object of class A ( Which points to the class B  // A O1 = new B(); // ) then
             * We can call and access the base class (Class A) Methods and data members
             * In this case the constructor of base class is called and we can assign the value to base class public data members(Inheritance - Is relationship ).
             */
            A O1 = new B();
            O1.a = 30;
            O1.Method_In_A();

            /*
             * We have two classes A and B.
             * Class B inherits class B.
             * if we create object of class B ( Which points to the class B  // B O2 = new B(); // ) then have access to all public methods and data members.
             */
            B O2 = new B();
            O2.a = 50;
            O2.b = 60;
            O2.Method_In_A();
            O2.Method_In_B();

            /*
             * We have two classes A and B.
             * Class B inherits class B.
             * if we create object of class B ( Which points to the class A  // B O3 = new A(); // ) then we get error as an explicit conversion exist (Inheritance concept).
             * below line will not work.
             */
            //B O3 = new A();

            Console.ReadLine();
        }
    }

    class A
    {
        public int a = 10;
        public A()
        {
            Console.WriteLine("Constructor Of A");
        }
        public A(int i)
        {
            i = a;
            Console.WriteLine("Param Constructor Of A", i);
        }

        public void Method_In_A()
        {
            Console.WriteLine("Method in A Called.");
        }
    }
    class B : A
    {
        public int b = 10;
        public B()
        {
            Console.WriteLine("Constructor Of B");
        }
        public B(int i)
        {
            i = b;
            Console.WriteLine("Param Constructor Of B", i);
        }
        public void Method_In_B()
        {
            Console.WriteLine("Method in B Called.");
        }
    }
}


Thursday, 22 March 2018

Having clause

Having clause
Having clause is similar to the where clause but it is used in the conjuction with group by clause in select statement
Group by clause with having clause used to filter the data or recordset.

Having clause folloed by group by and preced order by clause if used.

Following is the position of having clause

Select
From
Where
Group by
Having
Order by

Eg.
select TitleOfCourtesy from Employees
group by TitleOfCourtesy,BirthDate
having BirthDate >= CONVERT(datetime,'1950-10-12',101)


select TitleOfCourtesy from Employees
group by TitleOfCourtesy,BirthDate

having BirthDate >= '1960-10-12'

Monday, 19 March 2018

SQL Joins

SQL Join

SQL join is used to get the data from two or more table in the database.
A relation between the table is maintained by using the PK and FK reference.
 We can retrieve the data from two or more table using joins which containg some common values in both the table.

SQL join types

Inner join -  Retrieve the data from two or more table when there is matching records in both the table.


select a.FirstName,a.LastName, b.OrderID,b.ShipName,b.CustomerID
from
Employees a
inner join
Orders b
on
a.EmployeeID = b.EmployeeID
order by a.FirstName

Left join -  Retrive all the data from left table with matching records on right table


select a.FirstName,a.LastName, b.OrderID,b.ShipName,b.CustomerID
from
Employees a
left join
Orders b
on
a.EmployeeID = b.EmployeeID
order by a.FirstName

Right join – Retrive all the data from right table with matching records on left table.


select a.FirstName,a.LastName, b.OrderID,b.ShipName,b.CustomerID
from
Employees a
right join
Orders b
on
a.EmployeeID = b.EmployeeID
order by a.FirstName

Full join -  retrive data when there is matching records in one of the table.


select a.FirstName,a.LastName, b.OrderID,b.ShipName,b.CustomerID
from
Employees a
full join
Orders b
on
a.EmployeeID = b.EmployeeID
order by a.FirstName

Self join - is used to join a table to itself as if the table were two tables, temporarily renaming at least one table in the SQL statement.

Cartesian join - returns the Cartesian product of the sets of records from the two or more joined tables.

Friday, 16 March 2018

Cursor

Cursor

A cursor is a temporary work area created in the system memory when a SQL statement is executed. A cursor contains information on a select statement and the rows of data accessed by it.
This temporary work area is used to store the data retrieved from the database, and manipulate this data. A cursor can hold more than one row, but can process only one row at a time. The set of rows the cursor holds is called the active set.

There are two types of cursors in PL/SQL:

Implicit cursors
These are created by default when DML statements like, INSERT, UPDATE, and DELETE statements are executed. They are also created when a SELECT statement that returns just one row is executed. 

Explicit cursors
They must be created when you are executing a SELECT statement that returns more than one row. Even though the cursor stores multiple records, only one record can be processed at a time, which is called as current row. When you fetch a row the current row position moves to next row.

The cursor attributes available are
 %FOUND
 %NOTFOUND
 %ROWCOUNT
 %ISOPEN.
The status of the cursor for each of these attributes are defined in the below table. 
Attributes
Return Value
Example
%FOUND
The return value is TRUE, if the DML statements like INSERT, DELETE and UPDATE affect at least one row and if SELECT ….INTO statement return at least one row.
SQL%FOUND
The return value is FALSE, if DML statements like INSERT, DELETE and UPDATE do not affect row and if SELECT….INTO statement do not return a row.
%NOTFOUND
The return value is FALSE, if DML statements like INSERT, DELETE and UPDATE at least one row and if SELECT ….INTO statement return at least one row.
SQL%NOTFOUND
The return value is TRUE, if a DML statement like INSERT, DELETE and UPDATE do not affect even one row and if SELECT ….INTO statement does not return a row.
%ROWCOUNT
Return the number of rows affected by the DML operations INSERT, DELETE, UPDATE, SELECT
SQL%ROWCOUNT


For Example: Consider the PL/SQL Block that uses implicit cursor attributes as shown below:
DECLARE  var_rows number(5);
BEGIN
  UPDATE employee
  SET salary = salary + 1000;
  IF SQL%NOTFOUND THEN
    dbms_output.put_line('None of the salaries where updated');
  ELSIF SQL%FOUND THEN
    var_rows := SQL%ROWCOUNT;
    dbms_output.put_line('Salaries for ' || var_rows || 'employees are updated');
  END IF;
END;
In the above PL/SQL Block, the salaries of all the employees in the ‘employee’ table are updated. If none of the employee’s salary are updated we get a message 'None of the salaries where updated'. Else we get a message like for example, 'Salaries for 1000 employees are updated' if there are 1000 rows in ‘employee’ table. 

Friday, 9 March 2018

Use of caching in Asp.net (GidView Demo)

Post Content
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
using System.Data;
using System.IO;
using System.Web.Caching;
public partial class _Default : System.Web.UI.Page
{
    string strXmlAllDetails = string.Empty;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            getData();
        }
    }
    public DataSet getData()
    {
        DataSet dsAllDetailsOutput = (DataSet)Cache["mydata"];
        dsAllDetailsOutput = new DataSet();
        WebServiceDemoExample objWebServiceDemoExample = new WebServiceDemoExample();
        string strXmlOutput = objWebServiceDemoExample.FetchAllDetailsAdmin();
        XmlReader objXmlReader = System.Xml.XmlReader.Create(new StringReader(strXmlOutput));
        dsAllDetailsOutput.ReadXml(objXmlReader);
        Cache.Insert("mydata", dsAllDetailsOutput, new CacheDependency(Server.MapPath("")), DateTime.Now.AddHours(12), Cache.NoSlidingExpiration);

        if (dsAllDetailsOutput.Tables.Count > 0)
        {
            if (dsAllDetailsOutput.Tables[0].Rows.Count > 0)
            {
                GridView1.DataSource = dsAllDetailsOutput;
                GridView1.DataBind();

            }
        }
        return dsAllDetailsOutput;
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        DataSet ds = (DataSet)Cache["mydata"];
        GridView1.PageIndex = e.NewPageIndex;
        GridView1.DataSource = ds;
        GridView1.DataBind();
    }
}

Tuesday, 20 February 2018

Difference between Web.config and Machine.config:


Configuration files are used to control and manage the behavior of a web application.
  1. Machine.config:This is automatically installed when you install Visual Studio. Net.This is also called machine level configuration file. Only one Machine.config file exists on a server.This file is at the highest level in the configuration hierarchy.
  2. Web.config:This is automatically created when you create an ASP.Net web application project. This is also called application level configuration file. This file inherits setting from the Machine.config
Difference between Web.config and Machine.config:
  • The settings made in the Web.config file are applied to that particular web application only whereas the settings of Machine.config file are applied to the whole asp.net application.
  • Web.config file Setting of asp.net all project Machine.config are setting of server setting and when the web side are implemented time it work all project but Web.config file set all projects
  • Web config will be for that particular aplln whereas the Machine .config will for the whole machine
  • Every ASP.NET application that you has a Web.config file . The settings specified in this will imply only to that application.Whereas Your System will have a Machine.config file in Microsoft.NET\Framework\v1.1.4322\CONFIG Folder which contains specifications and settings at a system level.
  • Web.config file is to override the settings from the Machine.config file. Machine.config file settings are applied to all the webapplications residing on the server while Web.config settings are application specific.
  • Machine. config is configuration file for all the application in the IIS. but Web.config is a configuration file for a application or folder.
  • Machine.config for machine level configuration. but Web.config for a application/folder level configuration

Tuesday, 13 February 2018

is it possible to run my webpages on live site without web.config..?


Yes you can 
Because all the configuration settings will be available under MACHINE.CONFIG file by default these settings will be applied to all asp.net applications. The MACHINE.CONFIG file will be automitacally loaded when .net framework is installed.

it is something like if we had not defined the web.config the application will take the settings from the machine.config. the machine.config settings are overide by the web.config if u define the web.config for each running application.

In 2005 The VS When we trying to run first time any application the 2005 VS gives us warning that want to run application without web.config file.