Pages

Rabu, 21 September 2011

Kode koneksi VB.net dengan MS.Access

Import System.Data.OleDb
public class form1
  dim kns as new OleDbConnection
  dim da as new OleDbDataAdapter
  dim dt as new datatable
  Public Sub form1_load( ...... ) mybase.load
      'ini utk access 2003 kebawah
      kns.ConnectionString = "Provider = Microsoft.Jet.OleDb.4.0;data source=mydata.mdb;Jet Oledb:Database Password='passku'"
      'Ni tuk Access 2007 kebawah

    'kns.ConnectionString = "Provider = Microsoft.Ace.OleDb.12.0;data
source=*.mdb/*accdb;Jet Oledb:Database Password='passku'"
      da.SelectCommand=new oledbCommand("select * from tabel1",kns)
      da.fill(dt)
      datagridview1.datasource=dt
  end sub 
end class

Tidak ada komentar:

Posting Komentar

Related Posts Plugin for WordPress, Blogger...