Forum: VB.NET |
Thema:
Re: Zugriff auf eine Access 97 bzw. 2000 Datenbank |
Von:
Till Groos (
01.10.2003 16:27) |
Mit folgendem Code öffne ich eine Access Datenbank:
Imports System
Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim mycon As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Dokumente und Einstellungen\tg1\Eigene Dateien\Lehre\wochenbericht_neu.mdb;Persist Security Info=False")
Dim mycom As New OleDbCommand("Select * from bwoch", mycon)
Dim myda As New OleDbDataAdapter(mycom)
Dim myds As New DataSet
Try
myda.Fill(myds)
Me.DataGrid1.DataSource = myds.Tables(0).DefaultView
Catch ex As Exception
MessageBox.Show(ex.ToString)
Finally
If mycon.State = ConnectionState.Open Then
mycon.Close()
End If
End Try
End Sub
End Class
HTH
Till
mfgTill
Antworten
Vorsicht bei der Eingabe: Die Zeichen ' oder -- sind nicht erlaubt!