2. Visual Basic 6 ADO
Visual Basic 6 obsoletes the previously used
database access technology provided by Jet
This provides a new one known as ADO or Active
Data Objects
This technology allows users to access data
easily from many existing databases like Oracle
or MS SQL Server
ADO is quite simple and allows programmers to
provide flexible database front ends
3. Connection Object
This object represents an open connection to the
data source
This connection can be a local connection or can
be across a network
Key Properties and Methods
Property Methods
ConnectionString Close
Provider Open
ConnectionTimeout
CommandTimeout
CursorLocation
Mode
4. Command Object
A command object specifies a specific method
you intend to execute on or against the data
source accessed by an open connection
Key Properties and Methods
Property Methods
Key Properties and Execute
Methods
CommandText
CommandType
5. Recordset Object
The RecordSet object represents a complete set
of records from an underlying base table in the
database
RecordSet object references only one record at a
time as the current record
Key Properties and Methods Methods
Property
CursorLocation AddNew
CursorType Close and Open
EOF and BOF MoveNext
Fields MoveFirst
RecordCount MoveLast
MovePrevious
6. Putting These altogether
Define and open a Connection to a data source
Decide what data you need from the data source
and define Command objects that will retrieve this
data.
Retrieve the data you require by executing the
command objects and manipulate the data using
RecordSet objects.
7. Database Connectivity
Steps
Make a VB application that can be used to
connect to database
15. From here copy connection string and click ok
16. Establish Connection
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim cmd As New ADODB.Command
Private Sub Form_Load()
con.ConnectionString
="Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:Documents and
SettingsAdministratorDesktopEmployee.mdb"
con.Open
rs.Open "select * from employee", con,
adOpenDynamic, adLockOptimistic
cmd.ActiveConnection = con