download gratis video tutorial vb.net plus contoh aplikasi

cara cepat dan mudah export data sql server ke access dengan vb.net - bagian 2

 

 

 

Coding :


Imports System.Data.OleDb

 

Public Class Form1

 

Dim conn As OleDbConnection
Dim cmd As OleDbCommand

 

Sub Koneksi()
conn = New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=dbexport.mdb")
conn.Open()
End Sub

 

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Call Koneksi()

'CARA PERTAMA - MENGGUNAKANN FILE DSN

cmd = New OleDbCommand("insert into tblbarang select * from [odbc;filedsn=d:\cevest\dsnexport.dsn].tblbarang", conn)

'CARA KEDUA - MENGGUNAKAN DRIVER SQL SERVER

cmd = New OleDbCommand("insert into tblbarang select * from [ODBC;DRIVER=SQL SERVER;server=user-pc\sqlexpress;UID=;trusted_connection=Yes;database=12rpl3].tblbarang", conn)
cmd.ExecuteNonQuery()

 

End Sub


End Class