Connected Oriented Model

In Connected oriented Model, for each and every operation to the database like insert/update/delete, the client Application or front end will be performing an operation on the central database directly.

In this architecture, the programmer or a developer needs to open SQL connection before performing the operation like inserting the record, updating the record or deleting the record from the database table, once the operations to a database are done then the programmer needs to close SQL connection explicitly.


Objects to be used in Connected Oriented Model
  • Sqlconnection object.
  • Sqlcommand Object.
  • SqlDataReader object.
 Steps to communicate with SQL Server database. 

  • Including data provider into namespace .
             Using system.data.sqlclient ;
  • we have to use SQLconnection object by initializing and using the connection string parameter 
            string ConneString= "Server=Servername;database=database-name;userid=sa;password=abc;";
            Sqlconnection connection=new sqlconnection(conneString);

  • Here a developer needs to open the connection explicitly to perform certain operation to a centralized database .
            connection.Open();
  • we need to use command object by initializing SQL query/SQL command with the connection object reference name.
           Sqlcommand cmd=new Sqlcommand("Query to database like CRUD",connection);
  • we need to create datareader object.
           SqlDataReader drr=cmd.ExecuteReader();
  • Once the data reader fetches the record from the centralized database, we will bind this data from dataReader object to the client Application.
            GridView1.DataSource=dr;
  • After the execution is completed, the programmer needs to close the connection explicitly.

       connection.Close();
     
     

No comments:

Post a Comment

Xamarin Android Project App

Xamarin Android Project App 1. Xamarin -- Make a CALCULATOR Android App   https://drive.google.com/open?id=0B8OPCXLrtKPmWC1FWWtFM2lraVk...