* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Using Data Access Objects (DAO)
Serializability wikipedia , lookup
Extensible Storage Engine wikipedia , lookup
Entity–attribute–value model wikipedia , lookup
Relational algebra wikipedia , lookup
Team Foundation Server wikipedia , lookup
Tandem Computers wikipedia , lookup
Concurrency control wikipedia , lookup
Oracle Database wikipedia , lookup
Ingres (database) wikipedia , lookup
Microsoft Access wikipedia , lookup
Microsoft Jet Database Engine wikipedia , lookup
Database model wikipedia , lookup
Clusterpoint wikipedia , lookup
Relational model wikipedia , lookup
Microsoft SQL Server wikipedia , lookup
Using Active Objects
(ADO)
First convert your database to Access 97 by using Tools Database Utilities Convert
Database To Access 97 Format.
Next, start a Standard EXE project and ensure that in Project References you have
Microsoft DAO 3.6 Object Library selected and pushed as far up as it will go.
Add three buttons to the form; one to view all records, one to add a new record and one to
amend a record.
Private
Dim
Dim
Dim
Dim
Sub btnAddRecord_Click()
DB As Database
SQL As String
Forename As String
Surname As String
Forename = InputBox("Your forename")
Surname = InputBox("Your surname")
Set DB = OpenDatabase(App.Path + "\Example Database.mdb")
SQL = "INSERT INTO Person (Forename, Surname) VALUES('"
SQL = SQL + Forename + "', '"
SQL = SQL + Surname + "')"
MsgBox SQL
DB.Execute SQL
DB.Close
End Sub
Private
Dim
Dim
Dim
Dim
Sub btnAmendRecord_Click()
DB As Database
SQL As String
NewForename As String
OldForename As String
OldForename = InputBox("Old forename")
NewForename = InputBox("New forename")
Set DB = OpenDatabase(App.Path + "\Example Database.mdb")
SQL = "UPDATE Person SET Forename = '"
SQL = SQL + NewForename + "' WHERE Forename= '"
SQL = SQL + OldForename + "'"
MsgBox SQL
DB.Execute SQL
DB.Close
End Sub
Private
Dim
Dim
Dim
Sub btnViewAll_Click()
DB As Database
rsPerson As Recordset
SQL As String
Me.Cls
Set DB = OpenDatabase(App.Path + "\Example Database.mdb")
SQL = "SELECT * FROM [Person]"
Set rsPerson = DB.OpenRecordset(SQL, dbOpenDynaset)
rsPerson.MoveFirst
While Not rsPerson.EOF
Me.Print rsPerson.Fields("Forename") + " " +
rsPerson.Fields("Surname")
rsPerson.MoveNext
Wend
rsPerson.Close
DB.Close
End Sub