download gratis video tutorial vb 6 dan vb.net plus contoh aplikasi

cara koneksi vb.net dengan data excel

 

q1

q2

 

Imports System.Data.OleDb

 

Public Class Form2

Dim CONN As OleDbConnection
Dim DA As OleDbDataAdapter
Dim DS As New DataSet

 

Sub Koneksi()
'string koneksi ke data excel
CONN = New OleDbConnection("provider=Microsoft.ace.OLEDB.12.0;data source=book1.xlsx;Extended Properties=Excel 8.0;")
CONN.Open()
End Sub

 

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Call Koneksi()
DA = New OleDbDataAdapter("select * from [sheet1$]", CONN)
DS = New DataSet
DA.Fill(DS)
DGV.DataSource = DS.Tables(0)
DGV.Columns(1).Width = 250
DGV.ReadOnly = True
End Sub
End Class