|
Module Module1
Dim rs As ADO_NET_RecordSet_Library.RecordSet
Sub Main()
rs = New ADO_NET_RecordSet_Library.RecordSet
If Not rs.Connection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=database.mdb") Then
Console.WriteLine("Error while trying to connect to the database")
Exit Sub
End If
If Not rs.OpenRecordSet("SELECT * FROM Persons") Then
Console.WriteLine("Error while trying to open the recordset")
Exit Sub
End If
'run the list
Console.WriteLine("The database has these {0} persons", rs.RecordsCount)
Do Until rs.EOF
Console.WriteLine("ID: " & rs.FieldValue(0) & " Name: " & rs.FieldValue(1) & " Surname: " & rs.FieldValue(2))
rs.MoveNext()
Loop
Console.WriteLine()
'add a name
Console.WriteLine("Adding Joaquim Almeida")
rs.AddNew()
rs.FieldValue(1) = "Joaquim"
rs.FieldValue(2) = "Almeida"
rs.Update()
Console.WriteLine()
'run the list
Console.WriteLine("The database has these persons")
Do Until rs.EOF
Console.WriteLine("ID: " & rs.FieldValue(0) & " Name: " & rs.FieldValue(1) & " Surname: " & rs.FieldValue(2))
rs.MoveNext()
Loop
Console.WriteLine("The database now has these {0} persons", rs.RecordsCount)
rs.FindFirst("Surname", "Smith")
Console.WriteLine("Found {0} persons with the Surname 'Smith'", rs.RecordsFound)
Do Until rs.NoMatch
Console.WriteLine("ID: " & rs.FieldValue(0) & " Name: " & rs.FieldValue(1) & " Surname: " & rs.FieldValue(2))
rs.FindNext("Surname", "Smith")
Loop
End Sub
End Module
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.