Data base programming with


  1. Generally output of the program will be stored in RAM.
  2. RAM is volatile, that is after every execution RAM memory will be cleared.
  3. To store the data permanently, .net is providing two ways


  • File handling
  • Data base handling


Problems with File handling while storing real time data:-


101     teja             5000

102     raviteja         2000

102      Ravi              xyz

103       ravi             6000


  1. Number of columns are not restricted.
  2. Type of data is not allowed.
  3. Possibility for data redundancy.
  4. Different to manipulate the data.
  5. No security for the data.


  • To overcome these problems, ANSI introduced data base concepts

  • A collection of inter related data is called as data bases are divided in to three types




  • Create table EMP ( eno number, ename varchar 2 (10),…………..)
  • Create table XYZ


ADO.NET (Active X Data objects for .net)


  1. ADO.NET is an object library which is used to communicate with any data base.
  2. Object library means a set predefined classes (a set of name space)
  3. ADO.NET is used to develop client Server Applications.


C/S Architecture

  1. NET supports 2 types of connection




  1. Managed Connection
  2. Un managed Connection


Managed connection:

Managed connections works with the help of TDS  (Tabular data String) Protocol.


Un managed Connection:

Un managed connections works with the help of OLEDB(object linking and Embedding   Data  bases ) provides.

  • OLEDB providers are DLL files , which are COM components As Com is platform dependent , hence connection on OLEDB are called as Un managed connection.


Managed connections are faster in data accessing.



  1. To work with , Microsoft introduced System. Data Assembly , which   contains 8  Name spaces.
  2. these Name space are divided in to 5 Groups.


Group 1:- common name space

  1. System. Data
  2. System.Data.Common

  1. System . Data. SQL Types 


Group 2:- Un managed Name Spaces

4.System. Data. OLEDB (Supports all type of databases)


Group 3 :- Managed Name spaces

  1. System. Data. Sql client (sql server only)
  2. System. Data. oracle client (for oracle only ) (2.0)


Group 4:- ODBC Name space

  1. System. Data. ODBC (supports all Data bases)


Group 5 :- LINQ Related Name Spaces

  1. System. Data. LINQ


EX 1:- With oracle over Unmanaged connection

  1. A program to create a table in oracle


A procedure to find provider names automatically.


  1. Open notepad , save the file with the name


“one. UDL” and close it

File name        extension universal data Linker

  1. Double click on One .Udl file
  2. Select provider
  3. Choose “Micro soft oledb provider for oracle ” and click Next
  4. Provide User name and password of oracle and click ok.
  5. Right click on one.udl àopen with à note pad


  • Open WFAP
  • Place a button


Using System . Data. Oledb;


  • Code for Button 1 _click


Oledb connection con  = new oledb connection


(“User id = Scott ; password = tiger; provider = msdaora.1”);

Con. open ();

Message Box .show  (“Connections is ok”);

String q  = “Create Table c 194  (Eno number,  E name varchar 2 (10), Sql number)”;

Oledb command cmd = new oledb command  (q, con);



cmd. Execute Non query ()

Message Box. Show (“Table is created ”);


Catch (oledb Exception oe)


Message Box. Show  (oe. Message e );




Program to add records in to c 194 table:-


Insert  in to c 194 value  (101, ‘Teja’, 5000)


  • Open windows Forms Application Project
  • Design the form as shown Using System. Data . oledb
  • Code for Button 1_ click

String  s = “Insert in to c 194 values  (“ + text box1.Text  + “, ‘ “ + text box2. Text + “, ‘ “ + text box 3.text +”)”;

Message Box .show (s);

Oledb _connection con = new loedb connection

(“provider  = ms da or a.1 ; user id = scott;  password = tiger “);

Con. Open ();

Oledb command cmd = new oledb command  (s, con);

cmd. Execute  Non query ();

Message Box. Show (“Record is added”);