Attribute VB_Name = "mod1Oefeningen"
Option Explicit
Sub Oefening1()
Dim objCN As Object
Dim objRS As Object
Dim strBron As String
Dim strSQL As String
Set objCN = CreateObject("ADODB.Connection")
Set objRS = CreateObject("ADODB.RecordSet")
strBron = ThisWorkbook.Path & "\Bronnen\Databank.accdb"
strSQL = "INSERT INTO Contactpersonen (Voornaam) VALUES ('Miranda')"
With objCN
.ConnectionString = "Provider = Microsoft.ACE.OLEDB.12.0; Data Source = " & strBron
.Open
End With
objCN.Execute strSQL
Set objRS = Nothing
Set objCN = Nothing
End Sub
Sub Oefening2()
Dim objCN As Object
Dim objRS As Object
Dim strBron As String
Dim strSQL As String
Set objCN = CreateObject("ADODB.Connection")
Set objRS = CreateObject("ADODB.RecordSet")
strBron = ThisWorkbook.Path & "\Bronnen\Databank.accdb"
strSQL = "SELECT * FROM Contactpersonen"
With objCN
.ConnectionString = "Provider = Microsoft.ACE.OLEDB.12.0; Data Source = " & strBron
.Open
End With
With objRS
.Open strSQL, objCN
.MoveFirst
Do While Not objRS.EOF
Debug.Print .Fields("Voornaam").Value
.MoveNext
Loop
End With
Set objRS = Nothing
Set objCN = Nothing
End Sub
Sub Oefening3()
Dim db As cls1Oefeningen
Set db = New cls1Oefeningen
db.Toevoegen "Pietje"
db.Laad
Set db = Nothing
End Sub
Download hier het bestand.
