Friday, 11 December 2015

Connected and disconnected mode

Connected and Disconnected Data Access Architecture

The ADO.NET Framework supports two models of Data Access Architecture, Connection Oriented Data Access Architecture and Disconnected Data Access Architecture.
In Connection Oriented Data Access Architecture the application makes a connection to the Data Source and then interact with it through SQL requests using the same connection. In these cases the application stays connected to the database system even when it is not using any Database Operations.
ADO.Net solves this problem by introduces a new component called Dataset. The DataSet is the central component in the ADO.NET Disconnected Data Access Architecture. A DataSet is an in-memory data store that can hold multiple tables at the same time. DataSets only hold data and do not interact with a Data Source. One of the key characteristics of the DataSet is that it has no knowledge of the underlying Data Source that might have been used to populate it.
  DataSet ds = new DataSet();

In Connection Oriented Data Access, when you read data from a database by using a DataReader object, an open connection must be maintained between your application and the Data Source. Unlike the DataReader, the DataSet is not connected directly to a Data Source through a Connection object when you populate it. It is the DataAdapter that manages connections between Data Source and Dataset by fill the data from Data Source to the Dataset and giving a disconnected behavior to the Dataset. The DataAdapter acts as a bridge between the Connected and Disconnected Objects.
  SqlDataAdapter adapter = new SqlDataAdapter("sql", "connection");
  DataSet ds = new DataSet();
adapter.Fill(ds, "Src Table");


By keeping connections open for only a minimum period of time, ADO .NET conserves system resources and provides maximum security for databases and also has less impact on system performance.

Difference between stored procedure and function.


  • Stored Procedure have pre-compiled execuction plan where as functions do not.
  • Functions are used for computations where as procedures are mainly used for performing business logic.
  • Functions can only have 'in' parameter where as SP can have both 'in' and 'out' parameters.
  • Function does not allow DML (insert, update, delete) queries on an object where as SP allows.
  • Functions can be used inline where as SP can't be.
  • Stored Procedure can retun more than one value at a time while funtion returns only one value at a time.
  • Functions MUST return a value, procedures need not be
  • Thursday, 26 November 2015

    Delegate in c#

                Delegate                                                

      Delegate is a special data type that hold the address or reference of a function.


    There are two type of delegate.
    1)single cast delegate.
    2)multi cast delegate.

                        Single cast delegate.


    If we are using delegate object to store single function, then we said that it is single cast delegate.

                         Multi cast delegate.


    If we are using delegate object to store multiple function, then we easily said that it is multi delegate.

                             General syntax of delegate

    #create delegate.

    Access specifiers delegate name of delegate.
    E.g:-
    Public delegate my del();
    #procedure to create object of delegate and hold function into it.
    My del obj1=new My del ();
    #calling of function using delegate object.
    Obj1();= fun 1();

    Tuesday, 17 November 2015

    explanation of definition of ado.net

    Ado means active data object and ado is replaced by ado.net .Ado.net is fully based on oops concept.
    ADO.NET is a set of computer software components that programmers can use to access data and data services based on disconnected DataSets and XML. It is a part of the base class library that is included with the Microsoft .NET Framework. It is commonly used by programmers to access and modify data stored in relational database systems, though it can also access data in non-relational sources. ADO.NET is sometimes considered an active x data object.

    Sunday, 1 November 2015

    difference between interface and abstract class.

    Difference between interface and abstract class

    Interface provide pure abstract methods.
    Abstract class provide concrete classes.

    Interface provide multiple inheritance.
    Abstract class don't provide multiple inheritance.

    We cannot create object of interface, we create only reference variable of interface.
    We create object of abstract class.

    We cannot define data field within interface.
    In abstract class we have to define data field. 

    We cannot use any access specifier within interface.
    We can use access specifier with abstract class.

    Friday, 16 October 2015

    difference between c++ and c#.


    • C++ support operator overloading.
    • C# does not support operator overloading.
    • C++ contains header files.
    • C# contains namespaces.
    • C++ support multiple inheritance.
    • C# does not support multiple inheritance because it support interface.

    Saturday, 5 September 2015

    static in c#.net

    Static
    static is a keyword that behaves like type modifier.
    static works again oop and beyond the oops.
    static member are guest for a class.
    A static variable created only once in complete program whenever
    class is invoked only when application is closed.
    Example:-
    class class1
    {
    public int a,b;
    public static int c;
    public static int count=0;
    public class1()
    {
    count++
    message box.show("convert.To string")
    }






    class1 ob1=new class();
    class1.c=25;

    upcasting,downcasting,boxing,unboxing

    Up casting.

    Conversion of child data type into parent data type is
    known as up casting.

    Downcasting.

    Conversion of parent data type into child data type is
    known as downcasting.

    To execute downcasting process there is always need of
    type casting method.

    General syntax for downcasting.

    (type)expression

    ob2=(class2)ob1;

    Boxing

    Conversion of value type into object data type is known as boxing.

    Object behave like a universal data type because of boxing.

    Object obj;
    obj="helow";
    obj="7.5";

    unboxing

    conversion of object data type into value type is called unboxing.
    To executing unboxing process we always need of type casting.

    doubled=convert.to Double (obj);

    Diference between structure and class.

    Difference between structure and c lass.

    structure1.variable of structure define as value type variable.

    2.In case of structure compiler support static binding.

    class

    1.variable of class define as reference type variable.

    In case of class compiler support dynamic binding.


    Note=>in oops every class contain its own object or reference
    or pointer in same class with name This.

    This behave like owner of class.

    Rules of oops

    Rules of oops.

    First rule=>

    To access member of class from outside of class we have to create object of same class .

    General syntax to create object of class.

    class name object name=new class name();
    class1 obj 1 = new class1();

    class name object name();

    Example=>

    class1 customer 1;
    customer cusID=new customer;

    class class1
    private int a,b;
    public int c;
    public void set data1()
    {
    a=5;b=7;c=9;
    }
    public void set data2 (int x,int y,int z)
    {
    a=x;
    b=y;
    c=z;
    }
    public void set data3(int a,int b,int c);
    {
    a=a;
    b=b;
    c=c;
    }
    second rule=>


    Every object have three separate memory blocks.

    class1 ob 1=new class1();
    obj1.a=25;

    class1 ob 2= new class1();
    ob 2.b=5;
    ob 2.set data z(10,20,30);

    class1 ob 3=new class1();
    ob 3.set data 3(100,200,300);


    Class

    class

    class is a user defined data type it can contain following item into it.

    1.data field
    2.constructor.
    3.destructor.
    4.property.
    5.member function.
    6.indexer.
    7.delegate.
    8.event.
    9.attribute.

    Theory of class.

    1.Within class theory.
    2.outside class theory.


    =>To access member of class within same class is apart of within class theory.
    In within class theory there is no role of any access specifier.

    =>Outside of class exisibility of member is covered under outside theory.

    keyword for overriding

    keywords for overriding.

    1)Virtual=overridable.

    By default all methods are overridable.

    2)Override=overrides.

    If we are using override keyword with a function
    then this override keyword also more functions as virtual.

    3)Sealed=not overidable.

    4)Abstract=must overridable.

    *Abstract method must contain in abstract class.

    *A method followed by abstract keyword is known as
    abstract method.

    It has following limitation.

    1. Abstract method must contain in abstract class.

    2. Abstract method do not contain definition.It
    contain only signature of method.

    Tuesday, 11 August 2015

    Inheritance in c# and types of inheritance.

    Inheritance makes programs simpler and faster. With inheritance, we build several types upon a common abstraction. Then we later act upon all those types through the abstraction. We examine inheritance and polymorphism in the C# language.
    Base class:The class another class inherits from. In the C# language, the ultimate base class is the object class.
    Object
    Derived class:The class with a base class. A derived class may have multiple levels of base classes.

    Example. When you specify that a class derives from another class, the class you create acquires all the features of the base class. If the derived class has a few extra features but is otherwise the same as the base class, this is a good approach.
    Also:By using a base class, you can treat derived classes as the same base type and call virtual functions to access their features.
    Program using base class, virtual method: C#
    
    using System;
    using System.Collections.Generic;
    
    class Net
    {
        public virtual void Act()
        {
        }
    }
    
    class Perl : Net
    {
        public override void Act()
        {
     Console.WriteLine("Perl.Act");
        }
    }
    
    class Python : Net
    {
        public override void Act()
        {
     Console.WriteLine("Python.Act");
        }
    }
    
    
    
    There are different types of inheritance in c#.net
    and these are:-
    1)single inheritance.
    2)multilevel inheritance.
    3)hierarchical inheritance.
    4)hybrid inheritance.
    5)multiple inheritance.
    
    
    multiple inheritance and hybrid inheritance not support in c#.
    so we use interface.

    Saturday, 8 August 2015

    polymorphism

    Polymorphism provide facility by which we can use two or more than two funtion within same name in a class. we can achieve polymorphism using two technique;

    funtion overloading:

    It provide facility by which we can write two or more than two functions having same name withy different signature in a single class or in derived class.

    funtion overriding

    It provide facility by which we can write two or more than two functions having same name withy same signature in a single class or in derived class.



    Monday, 3 August 2015

    Definition of funtction

    Function

    Function is a separate block of code that is used to reduce complexity
    of program.

    function is a concept by which we connect two or more than two machine
    and two or more than two destination and also transfer data from two or
    more than two machine.

    Access specifier in c#.net

    Types of  access specifier in c#.net

    1)Private=private access specifier is a specifier which accessible
     within class.This access specifier is so secure.this is most
    commonly used access specifier.

    2)protected=Accessible within namespace or assembly.It only occurs
    in parent child relationship(inheritance).

    3)public=Accessible anywhere.

    4)Internal=It is accessible anywhere.By default C# contain
    internal access specifier.

    5)Partial=It is used to class or interfaces into or more than
    two parts.

    Saturday, 1 August 2015

    coding of customer management system (add and delete)

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;

    namespace Customer_management_system
    {
        public partial class Form1 : Form
        {
            struct customer
            {
                public int customerID;
                public string firstname;
                public string lastname;
                public DateTime dateofbirth;
            }
            customer[] cus = new customer[1];
            int index = 0;
            public Form1()
            {
                InitializeComponent();
            }

            private void btnadd_Click(object sender, EventArgs e)
            {
                cus[index].customerID = Convert.ToInt32(txtcusid.Text);
                cus[index].firstname = txtfirstname.Text;
                cus[index].lastname = txtlastname.Text;
                cus[index].dateofbirth = Convert.ToDateTime(txtdateofbirth.Text);
                index++;
                Array.Resize(ref cus, cus.Length + 1);
                MessageBox.Show("customer added successfuly");
           

            }

            private void btnsearch_Click(object sender, EventArgs e)
            {
                for (int i = 0; i < index; i++)
                {
                    if(cus[i].customerID==Convert.ToInt32(txtcusid.Text))
                    {
                        txtfirstname.Text = cus[i].firstname;
                        txtlastname.Text=cus[i].lastname;
                        txtdateofbirth.Text=cus[i].dateofbirth.ToString();
                        return;
                       
                    }
                }
                MessageBox.Show("cus id not found");
                       
                   
            }
        }
    }

    Friday, 31 July 2015

    Intro of .net

    .NET IS A FRAMEWORK THAT SUPPORT MULTIPLE LANGUAGES. 

    It supports more than 60 languages.
    Like c# and vb.