About OLEDB connection & command class in C# .net

About OLEDB connection class :

  1. This class is used to open a connection with any type of data base and also used to start transactions.
  2. This class is inherited from System. Data. Common .Connection class,

Which is an abstract  class.

Screenshot_19

AS per above observations , all types of connection classes will be having same method names and same property names.

Properties:-

  1. Status:
  2. Server version:
  3. Connection String:
  4. Provider:

Methods:-

  1. open ()
  2. close ()
  3. Dispose ()
  4. Begin Transaction

 

 

Con. open ();

Con . close ();

Con.  Open ();

About oledb command class :

  • This class is used to execute DDL, DML, TCL, QL and Stored procedures.

 

DDL:  create, alter, drop

DML:  insert, delete, update

TCL: commit, rollback, save point

QL: select

 

Stored Procedure is a collection of SQL Statements.

 

Properties:-

  1. Connection
  2. Command Text
  3. Command Type
  4. Parameters

 

Methods:-

  1. Execute Non Query () :- is used to execute DDL, DML, TCL and stored procedure.
  2. Execute Reader (): need to be used when multiple records are expecting from a select statement.

Execute Reader ()   returns Data reader.

  1. Execute Scalar (): Search only for first match, it match is found ,then only first column value will be returned.

 

EMP 

 

ENO           ENAME                   SAL

1                  Ravi                         5000

  1. Teja 9000
  2. Raj 8000
  3. .

1000

 

Select * from EMP ;

Execute Reader  () ALL

Execute Scalar ()  ALL