VB 2008: Creare conexiune Microsoft Access 2003

Daca ati inceput de curand sa lucrati in Visual Basic 2008 si nu stiti cum sa creati o conexiune catre o baza de date Microsoft Access, mai jos aveti la dispozitie un mic exemplu.

Dim Cnn As New OleDb.OleDbConnection()
Cnn.ConnectionString = "Provider=Microsoft.Jet.OleDb.4.0; " & _
"Data Source=" & Application.StartupPath & "\data.mdb;" & _
"Persist Security Info=False;"
Cnn.Open()

MsgBox("Connection established!")

In exemplul de mai sus, baza de date(data.mdb) se afla in folderul proiectului(..\bin\debug\data.mdb).

 

Adaugă un răspuns

Your email address will not be published. Required fields are marked *