/* */

Monday, April 18, 2011

[belajar-access] Re: Koneksi ODBC Access

File DSN :

'isi d:\temp\dsnaccdb.dsn
'[ODBC]
'DRIVER=Microsoft Access Driver (*.mdb, *.accdb)
'UserCommitSync = Yes
'Threads = 3
'SafeTransactions = 0
'PageTimeout = 5
'MaxScanRows = 8
'MaxBufferSize = 2048
'FIL=MS Access
'DriverId = 25
'DefaultDir=D:\temp
'DBQ=D:\temp\datanya.accdb


Modul pada database yang akan membuka tabel di database lain :

Sub bukatabel()
' tools reference aktifkan/centang :
' Microsoft Activex Data Object 2.6
Dim cn As ADODB.Connection
Set cn = New ADODB.Connection
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset

cn.Open "FileDSN=d:\temp\dsnaccdb.dsn" ' ,myuserid, mypassword
rst.Open "Table1", cn
If rst.EOF Then GoTo labelexit
rst.MoveFirst
While Not rst.EOF
MsgBox rst.Fields("nama").Value & " Tgl Lahir " & Format(rst.Fields("tanggal").Value, "dd mmm yyyy")
rst.MoveNext
Wend
labelexit:
rst.Close
cn.Close
End Sub


'=====


--- In belajar-access@yahoogroups.com, him mah <himmah.mlg@...> wrote:
>
> Maaf pak, kalau nama Data Source Name apa ya
>
> 2011/4/17, hari yanto <har_i20002000@...>:
> > Coba gunakan script ini (taruh di module karena digunakan dibanyak form):
> >
> > Public Kon As ADODB.Connection
> > Public Function KonAC(Optional ByVal serverName As String = "", _
> >    Optional ByVal userName As String = "", Optional ByVal userPass As String
> > = "", _
> >    Optional ByVal dbPath As String = "", Optional ByVal dbName As String =
> > "") As Boolean
> >    Dim strCon As String
> >    On Error GoTo errHandle
> >         If Len(userPass) > 0 Then
> >            strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " &
> > dbPath & "\" & dbName & ";" & _
> >            "Jet OLEDB:Database Password=" & userPass & ""
> >         Else
> >            strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " &
> > dbPath & "\" & dbName & ""
> >         End If
> >    Set Kon = New ADODB.Connection
> >    Kon.ConnectionString = strCon
> >    Kon.Open
> >    KonAC = True
> >    Exit Function
> > errHandle:
> >    KonAC = False
> > End Function
> >
> > Cara penggunaannya:
> > buat fungsi:
> > Function ToACC()
> > dim tt1, tt2 as variant
> > Dim result  As Boolean
> >
> >     result = KonAC(, , "'" & pass & "'", tt2, tt1)
> >     'tt2 = path tanpa diakhiri \, krn sudah masuk di module
> >     'tt1 = nama database (misal contoh.mdb)
> > End Function
> >
> > Gunakan:
> >        If Kon.State <> 0 Then
> >             MsgBox "Koneksi sukses"
> >         Else
> >             MsgBox "Gagal"
> >         End If
> >        Kon.Close
> >        Set Kon = Nothing
> >
> > Semoga bisa membantu dan memberi semangat...
> >
> > Hariyanto (Surabaya)
> >
> > --- On Mon, 18/4/11, him mah <himmah.mlg@...> wrote:
> >
> >
> > From: him mah <himmah.mlg@...>
> > Subject: [belajar-access] Koneksi ODBC Access
> > To: "belajar-access" <belajar-access@yahoogroups.com>
> > Date: Monday, 18 April, 2011, 9:04 AM
> >
> >
> >
> >
> >
> >
> > Assalamu'alaikum Wr. Wb
> > Mau tannya tentang koneksi ODBC access
> >
> > biasanya kalau kita buat koneksi langkahnya seperti ini
> >
> > 1. Buka icon Administrative Tools pada Control Panel anda.
> > 2. Double-click pada icon disi Data Sources (ODBC).
> > 3. Pilih Tab System DSN.
> > 4. Klik pada Add dalam Tab System DSN.
> > 5. Pilih Microsoft Access Driver. Click Finish.
> > 6. Pada Layar Berikut, click Select ke lokasi database.
> > 7. Beri nama Data Source Name (DSN).
> > 8. Click OK.
> >
> > bisa ngga langkah-langkah tersebut dibuat di VBA Access (tanpa harus
> > masuk kontrol panel)
> > misal kita akan buat Data Source Name (master) yang lokasi database
> > nya ada di c:\master\master.accdb
> >
> > terima kasih
> >
> >
> >
> >
> >
> >
>


------------------------------------

SPAM IS PROHIBITEDYahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/belajar-access/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/belajar-access/join
(Yahoo! ID required)

<*> To change settings via email:
belajar-access-digest@yahoogroups.com
belajar-access-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
belajar-access-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/

No comments:

Post a Comment