Sunday 31 March 2013

Components of Ado.Net

Hello friends !! Today  I am just going to  explain about component of ado.net which is as given below..
Component of Ado.Net: 
There are two component of ado.net which are explain as given below
  1. DataProvider.
  2. DataSet.
DataProvider:
  1. The main task of data provider is providing the data.
  2.  DataProvider is used for connecting database executing command and retrieving result also.
  3. DataProvider is a software component  enabling an Ado.Net consumer to interact with a data source.
  4. DataProvider make the connection with data source
  5. There are some data provider for example MYSQL (Structure Query Language), OLEDB (Object Linking Embedded Database),ODBC (Object Database Connectivity ) 
    DataProvider has main object which are explain as given below:
  •            Sqlconnection
  •       Sqlcommand
  •      Sqldatareader.
  •        SqlDataAdepter 

  • Sqlconnection:

    ·         Sqlconnection is an object used to make connection with database.
    ·         We make instance of sqlconnection which is take connection string as argument and pass the value to the constructor statement.
    ·         There are two type of connection we make which is as given below 
      1.     Open();
      2.     Close();

    Open();: The Open(); method we used for open the database connection.
    Close();The Close(); method we used for Close the database connection.

    Syntax:


    SqlConnection con=new SqlConnection(“data source=.;initial catalog=project2;integrated security =true”);

    Note:

    Data source=.;  (this tell your server name)
    .  (Dot means your current server name)

    Initial catalog =project2;   (tell your database name)
    (Project2 is a database name)

    Integrates security=true (it tell you that you are login in the sql server with window authentication)

    Note: if you login with Sql server authentication then you have to give here id and password instead of integrated security =true as given below:
    User Id=sandeep;
    Password=soni;

    The output screen will you see as given below:

          I hope this post will help you..
          If u have some query regarding to this article then please post your comment .your comment will be    appropriate 


0 comments:

Post a Comment

Hey thanax alot to comment i will revert you back soon...

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites