Featured

    Featured Posts

Object Database Connectivity (ODBC)

ODBC is a Windows Technology, that lets a database client application connect to an external database.  To use ODBC the database vendor must provide an ODBC driver for data access.  Once this driver is available, the client machine should be configured with this driver.
     The destination of the database, the login id & password should also be configured on client machine.  This is called as data source.  The user can configure multiple data sources with same or different drivers on the same machine thus using ODBC, it is possible to access heterogeneous data from any client.
figure here.....

ADO -> ActiveX Data Object :

        ADO "flatterns" the object model used by DAO and RDO, meaning that it contains fewer objects and more properties, methods & events.
       This is a programming model that eliminates the need to choose from among DAO and RDO and all other data access methods.
       ADO is essentially an interface to OLEDB.  OLEDB- is low-level object based programming interface designed to access a wide variety of data sources.  That is, OLEDB is not restricted to ISAM, Jet or even relational data sources.  It can support both relational and non relational data sources.  The idea behind OLEDB is universal data access with this type of data, we can access unstructured data, such as text file and excel spreadsheets.
       OLEDB is not designed to be accessed directly, in VB due to its complex interface but virtually all of the OLEDB's functionality is exposed by ADO.  ADO encapsulates OLEDB functionality & exposes it as objects.
figure here
        ADO uses a new database connection frameworks called OLEDB, which allows faster, more flexible access to multiple data providers and ADO wraps it all into one easy to use interface.  This means that we can write databases applications that can easily scale from single user database ( such as Access) to complex client\server system (such as oracle, SQL servers).

ADO Object Model :->

      A connection object represents connection to a databases.  The databases can be relational ( eg SQL server) or non-relational ( like MS-Excel).
       The command object represents an SQL statement such as select or insert or some other data provider specific commands.
       The Recordset object is used to view and manipulate data ( much like DAO's recordset and RDO's Resultset).

Databound Controls :->

         Controls that we can directly bind to a database or viewing, editing, adding and deleting data are known as data bound controls. These controls provides extensive functionality.
        Data Grid control is a spread-sheet like control that displays a series of rows and coloums representing record and fields.  Recordset object use the Data Grid control to create an application that allows the end user to read & write to meet database.
      Bound controls can be quickly configured at design time with little or no code.  When we use the control's data source property at design time, the control is automatically filled in and automatically set from the data source's recordset.

Program

Database Connectivity in Visual Basic using ADO (ActiveX Data Object )
  1. Project -> Commponents -> References -> MSADO 2.0 Library.
  2. Take ADO control ( Project -> Components -> ADO control) and add to it to form.  Copy the connection string from it and then remove the control or make it invisible using property " false ".
General declrations :

Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Private Sub Cmddelet_click()
Dim str As string
str = " are you sure you want to delete "
If MsgBox(str, Vb Yes\No Cancel) = Vb Yes Then
rs.Delte
Text1.text =""
Text2.text = ""
Text3.text = ""
MsgBox( " data deleted ")
else
MsgBox( " no deletion")
End if
End Sub

Private Sub Cmdexit_click()
rs.close
cn.close
End
End Sub

Private Sub Cmdfirst_click()
rs.MoveFirst
call display
End Sub

Private Sub Cmdlast_click()
rs.MoveLast
call display
End Sub

Private Sub Cmdnew_click()
Text1.text = ""
Text2.text = ""
Text3.text = ""
Text1.SetFocus
End Sub

Private Sub Cmdnext_click()
rs.MoveNext
If rs.EOF Then
MsgBox(" you are in last record ")
rs.Movelast
Else
call display
End if
End Sub

Private Sub Cmdprev_click()
rs.MovePrevious
If rs.BOF Then
MsgBox( " you are in First record " )
rs.MoveFirst
Else
call display
End if
End Sub

Private Sub Cmdsave_click()
Dim str As String
rs.AddNew
If rs.EditMode = ad Edit Add Then
rs(" roll no") = Text1.Text
rs(" name" ) = Text2.Text
rs(" class " ) = Text3.Text
End if
End Sub

Private Sub Form_Load()
with Form1
.Top = 500
.Left = 600
.Height = 6915
.Width = 7290
End with
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.Open = ( "provider = Microsoft.Jet.OLEDB 4.0; Data source = C:\student mdb; cn; adopendynamic, adlockoptimisti " )
rs.open " select*From Table", cn, adopenDynamic, adlock Optimistic
End Sub

Private Sub display()
Text1.Text = rs(" roll no ");
Text2.Text = rs(" name ");
Text3.Text = rs(" class ");
End Sub

Post a Comment

www.CodeNirvana.in

www.posthatke.com. Powered by Blogger.

Google+ Followers

Copyright © www.posthatke.com | Blogger Templates | Designed By posthatke.com