Friday 25 October 2013

SQL

SQL :

SQL - Structured Query Language..

 SQL Mainly Use Data & Information are Stored ..

DataBase :

  DataBase is a Collection Of Tables..

 Table :

 Tables are COllection Of Rows and Columns..

2 type Languages


DDL - Data Defination Language 
DML - Data Manipulation Language


  DDL Statements :
              * CREATE 
              ALTER 
              DROP

 DCL Statements :
          
                * INSERT
             * UPDATE
             * DELETE
             * SELECT

SQL Constraints :

          PRIMARY KEY
          NOT NULL
          CHECK
          UNIQUE
          FOREIGN KEY
          DEFAULT

SQL Data Types :

         Int
         Varchar(size)
         Float
         Decimal
         Single
         Double
         DateTime
         Identity

Primary Key :

       Not Accepted Null Values..
       Not Accepted Duplicate Values..
       One Table One Primary Only Use..

UNIQUE Key :

     (Same as Primary Key)
     But Is Accepted One Null Value..
     One Table More then Unique Keys are Use..

FOREIGN Key:

    One Table to Another Table Refrences to Use ForeignKey..
    One Table PrimaryKey to Another Table Called as Reference Key..

SQL Objects :

        *  Tables
        *  Stored Procedure
        *  Function 
        *  Trigger
        *  Cursor
        *  Index
        *  View

Stored Procedure :

           Reusability ..
           PreCompailed ..
           Set Of Querys ..
           Perfomance Fast ..
           Less Traffic ..
           Security Of Your Data..

Function :

Function 2 Types..
     *  Aggregate Functions
     *  Scalar Functions

 Aggregate Functions :

          MAX()
          MIN()
          COUNT()
          AVG()
          SUM()
          FIRST()
          LAST()
Scalar Functions :
   UCASE()
   LCASE()
   NOW()
   LENGTH()

 Trigger :

  Insert,UpDate,Delete Get Excuted automatically Trigger is Called..

 INDEX :
  Index Is a Book..(Book Index First Page)..
  table Columns Create INDEX..
  Performance Fast..
 Types:
   Clusted Index
   Non-Clusted Index

 View :
  View Is a Set Of Select Query ..

Delete Truncate:

 Delete Where Condition Use.. 
 Truncate are Not Use for any Conditions..
 Delete Row By Row Delete
 Truncate Table Delete

 Delete Identity Column Not Reset..
 Truncate Identity Column Reset..

 Delete Trigger Fired..
 Truncate Cannot Trigger Fired ..

 Delete is Slowly Record Delete..
 Truncate is Quickly Delete..

 Delete Can Roolback..
 Telete Cannot Roolback..
  

Syntax :

DataBase:
 Create DataBase DataBaseName;
 Use DataBase DataBaseName;

 Create DataBase Vijay_DB;
 Use DataBase Vijay_DB

Table 
 Create Table TableName
  (
     ColumnName DataTypes,
     Name Varchar(250),
     ...,
     ...
  )
 Create Table Actor_Details
  (
    Act_ID Int,
    Act_Name Varchar(100),
    Act_Salary Decimal(10,2)
  )
Insert :

 Insert Into TableName (ColumnName1,ColumnName2,.....)
       Values('aaa','aaa')
 Insert Into Actor_Details(Act_Name,Act_Salary)
       Values('Ajith',10000)


Selecct :

 Select * From TableName;
 Select * From Actor_Details;

Tuesday 22 October 2013

WaterMark Textbox using Java Script

WaterMark Textbox using Java Script : 

 JavaScript :

<script type = "text/javascript">
        var TextBoxText = "Enter Your Name";
        function WaterMark(txt, evt) {
            if (txt.value.length == 0 && evt.type == "blur") {
                txt.style.color = "gray";
                txt.value = TextBoxText;
            }
            if (txt.value == TextBoxText && evt.type == "focus") {
                txt.style.color = "black";
                txt.value = "";
            }
        }
</script>


   Name :
    <asp:TextBox ID="txtName" runat="server" Text = "Enter Your Name"
         ForeColor = "Gray" onblur = "WaterMark(this, event);"
         onfocus = "WaterMark(this, event);">
</asp:TextBox>
        <asp:Button  ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click"/>







Tuesday 15 October 2013

OOPS Concept C#

OOPS Concept C# :


  •   Class
  •   Objects
  •   Inheritance
  •   Polymorphism
  •   Inheritance
  •   Data Abstraction & Encapsulation
  •   MessagePassing
  •   Dynamic Binding

  Class :

                 *  It Is a Template..
                 *  It Is Collection of Methods,Function and Member Variables..
                 *  One or More different Method's are different DataTypes
                     Called as Class..

      

 Objects :

                 *  It is a Entity.
                 *  One Class When Object Create allocate the Memory..  

 Data Abstraction :

                 It is a Hiding Techinque.
                 Same as Access Modifers..
                          
                     * Public
                     * Private
                     * Protected
                     * Internal
                     * Protected Internal  

 Polymorphism:

                  *  It is a Duplicate Classes..
                  *  Method Names are Same.. 
                But Different types of Parameters..(Three types of)
                          
                      * Number Of Parameters
                      * Count Of Parameters
                      * Order Of Parameters
                               
                          RunTime Polymorphism  (Overriding)
                 CompileTime  Polymorphism  (overloading)

Inheritance :

             *  Reusability..
              One Class to another Class Inherited.. 
             *  One Class to another Class Calles as Inheritance..
             *  Parent Class to Child Class..
             Inheritance Types :

                * Single Inheritance
                * Multiple Inheritance
                * MultiLevel Inheritance..

InterFace  :

          *  InterFace is a Incomplete Class..
         *  Can not be Create Object.. 
         *  Method Names and Members variables Declare Only Not have                               Implementation.. 
         *  When One Class to InterfaceClass are Inherited Declare Methods
                 and Member variables are Must Have  Implemention..
         *  One Intrerface to another Interface Inherited..
         *  InterFace to Abstract Inherited..
         *  Abstract  to Interface Not Inherited..

Abstract :

            (Same as Interface)
            (Method Names and Members variables are
               Declare and Implementation..)
           *  Abstract is a Incomplet Class..
           *  Can not be Create Object.. 
           *  Method Names and Members variables are
                   Declare and Implementation..
           *  When One Class to AbstractClass Inherited Declare Methods
                   and Member variables are Must Have  Implemention..
            One Intrerface to another Interface Inherited..



 Partial Class :


          Class Names are Same..
          One or More Class Names are Same..
          But Mehod Names Different..

  Static Method :

           Cannot Create Object..

 Scaled Class :


          Scaled Class Not Inherited to Another Class..

 Constructor :


           Class Name and Methods Names are Same.. 
           Once Object Create Costructor Automatically Methods
                  will be Called..

Wednesday 2 October 2013

sql trigger Insert,update Example

sql trigger Insert,update Example :

 
 - - Create Table - -

Create Table Employee
(
ID  Int Primary Key Identity(1,1),
Name Varchar(100),
Occuption Varchar(100),
Address Varchar(100),
Salary Decimal
)

- - Sub Table - -
Trigger Fire This Table Insert

Create Table Employee_Trig
(
ID  Int Primary Key Identity(1,1),
Name Varchar(100),
Occuption Varchar(100),
Address Varchar(100),
Salary Decimal,
       EmpID Int
)


 - - Create Trigger - -

Syn

Create Trigger TriggerName
ON TableName For Insert,Update,Delete 
AS
BEGIN
     .....
      ...
END
---

 - - InsertTrigger - -

Create Trigger Trig_Employee
ON Employee FOR Insert           -->Insert 
AS
DECLARE 
@ID Int,
@Name Varchar(100),
@Occuption Varchar(100),
@Address Varchar(100),
@Salary Decimal
BEGIN
Select @ID=i.ID From Inserted i
Select @Name=i.Name From Inserted i
Select @Occuption=i.Occuption From Inserted i
Select @Address=i.Address From Inserted i
Select @Salary=i.Salary From Inserted i
Insert Into Employee_Trig(EmpID,Name,Occuption,Address,Salary)
Values(@ID,@Name,@Occuption,@Address,@Salary)
END

Insert Into Employee(Name,Occuption,Address,Salary)
Values('aaa','Dev','chennai',1000)

Select * From Employee_Trig

 - - Update  Trigger - -

Alter Trigger Trig_Employee_Update
ON Employee FOR Update               - ->Update Trigger           
AS
DECLARE 
@ID Int,
@Name Varchar(100),
@Occuption Varchar(100),
@Address Varchar(100),
@Salary Decimal
BEGIN
Select @ID=i.ID From Inserted i
Select @Name=i.Name From Inserted i
Select @Occuption=i.Occuption From Inserted i
Select @Address=i.Address From Inserted i
Select @Salary=i.Salary From Inserted i
Insert Into Employee_Trig(EmpID,Name,Occuption,Address,Salary)
Values(@ID,@Name,@Occuption,@Address,@Salary)

END



Update Employee Set Name='vijay' Where ID=2

Select * From Employee


Select * From Employee_Trig
-- Trigger Fired Table --