0% found this document useful (0 votes)
28 views2 pages

Modul 8

This document provides code to connect to an Access database file (.mdb) located at E:\FROM COLLEGE\PART5\VB.NET 2008\1.mdb using OleDb. It imports the System.Data.OleDb and System.Data namespaces. When a button is clicked, it creates an OleDbConnection object, defines the connection string, opens the connection, and displays a message if successful or catches any errors. The connection is closed at the end to clean up resources.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views2 pages

Modul 8

This document provides code to connect to an Access database file (.mdb) located at E:\FROM COLLEGE\PART5\VB.NET 2008\1.mdb using OleDb. It imports the System.Data.OleDb and System.Data namespaces. When a button is clicked, it creates an OleDbConnection object, defines the connection string, opens the connection, and displays a message if successful or catches any errors. The connection is closed at the end to clean up resources.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Koneksi ke Datasource Script : ' Impor namespace System.Data.OleDb Imports System.Data.

OleDb Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click Dim conn As OleDbConnection = Nothing ' Misal file DB adalah C:\MyDB.mdb Dim ConnStr As String = _ "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source= E:\FROM COLLEGE\PART5\VB.NET 2008\1.mdb;" Try ' Menciptakan objek dan membuka koneksi conn = New OleDbConnection(ConnStr) conn.Open() MessageBox.Show("Connected with : " + conn.DataSource _ + vbCrLf + "Provider : " + _ conn.Provider, "Connected") Catch ex As OleDbException MessageBox.Show(ex.Message.ToString, "Disconnected") Finally ' Membersihkan alokasi objek di memori If conn IsNot Nothing Then conn.Close() End Try End Sub End Class

Hasil :

You might also like