See, here I am going to explain for all concerned in this
forum, about the two types of Data access objects which
you can use in your VB (?). There are so many postings
on this subject.
The duo is DAO & ADO. It is not misspelled acronym like
DAO (Data Access Object)
DAO is a data access technology primarily designed to
use the Jet databases like Microsoft Access or dBase,
ADO (ActiveX Data Objects)
ADO uses the OLE DB (Object Linking & Embidding- forget
about it, if you don't understand it at this juncture),
technology to gain access to any type of data source.
The ADO object model is based on three types of objects
namely Connection, Command and Record set.
The connection object holds data source connection
information like data source name, its location, the
user id and password, the name of the OLE DB provider,
etc. The command object is used to execute SQL
commands, queries and stored procedures. The Record set
object holds the results returned by the queries and
used for adding records to the tables and updating the
In ADO, "CurrentProject. Connection" determines the connection string.
The connection string is:
Provider=Microsoft.Access.OLEDB.10.0; Persist Security
Info=False; Data Source=Server ip address or name;
UID=sa; PWD=sa;Initial Catalog= Database Name;
Opening and Adding Value to a Record Set
Let us now examine how to open and add value to a
recordset using DAO and ADO.
1 st - The DAO code:
Dim db as Database
Dim rs as DAO.Recordset
Set db = CurrentDb( )
Set rs = db.OpenRecordset(“tblPeople”)
rs(“TextFieldName”) = “New Value”
2 nd - The ADO Code:
Dim rs As New ADODB.Recordset
rs.Open "tblPeople", CurrentProject.Connection, _
rs("TextFieldName ") = NewValue
Executing a Query
The DAO way:
db.Execute "SELECT …."
The ADO way:
Dim CommandText As String
CommandText = "SELECT…….."
rs.Open CommandText, CurrentProject.Connection, _
adOpenStatic, adLockReadOnly, adCmdText
These changes are to be made throughout the code in the
application when ever you wish to change the