Access lesen
Lesen aus einer Access-Datenbank:
''
Tabelle: Create Table Person
' (Persnr Integer, Name Char(10), Vorname Char(10))
'
Dim conn As New OleDb.OleDbConnection()
Dim abfrage As New OleDb.OleDbCommand()
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Password="""";"
conn.ConnectionString += "User ID=Admin;"
conn.ConnectionString += "Data Source=C:\tmp\db1.mdb;"
abfrage.Connection = conn
abfrage.CommandText = "SELECT * FROM Personen"
conn.Open()
Dim ergebnis As OleDb.OleDbDataReader
ergebnis = abfrage.ExecuteReader
With ergebnis
While ergebnis.Read
WriteLine(" {0},{1},{2}", _
.GetInt32(0), .GetString(1), .GetString(2))
End While
End With
ergebnis.Close()
conn.Close()
|