OleDBCommand neni treba definovat... Pokud Vas projekt ten typ nezna, chybi:
Imports System.Data.OleDb
Deklarace a funkce vypada takhle:
Public con As New OleDb.OleDbConnection
Public Function Connection() As Boolean
Dim intCounter As Integer = 0
If Not File.Exists(ProgDataPath) Then
MsgBox("Nemate nastavenou cestu k databazi")
Return False
Exit Function
End If
Try
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & ProgDataPath & ";Persist Security Info=False"
con.Open()
Catch exo As OleDb.OleDbException
MessageBox.Show(exo.Message)
Return False
End Try
Return True
End Function
V globalni promenne ProgDataPath mam nastavenou celkou cestu k databazi (kuprikladu D:\Data\data.mdb")
|