Berikut Selengkapnya :
Coba buat form seperti berikut :
Kita akan mengisikan kode pada Tombol “Connect ODBC” dan “Connection String”
1. Tombol Connect ODBC
Private Sub cmdConnectODBC_Click()
On Error GoTo erhan
Dim Objcnn As New ADODB.Connection
Dim SQLString As String
SQLString = “DSN=RyanOra;UID=ryan;PWD=Killme;”
Objcnn.Open SQLString
Objcnn.CommandTimeout = 0
MsgBox “Sucess”
Exit Sub
erhan:
MsgBox Err.Description
End Sub
Kode diatas dapat dijalankan,d engan Asumsi, Kita sudah membuat ODBC data sourcenya dengan Nama : RyanORa
2. Tombol Connection String
Private Sub CmdConStr_Click()
On Error GoTo erhan
Dim Objcnn As New ADODB.Connection
Dim SQLString As String
SQLString = “Provider=OraOLEDB.Oracle.1;Password=itonly;Persist Security Info=True;User ID=ryan;Data Source=ORARYAN”
Objcnn.Open SQLString
Objcnn.CommandTimeout = 0
MsgBox “Sucess”
Exit Sub
erhan:
MsgBox Err.Description
End Sub
Kode diatas menerangkan, cara koneksi untuk ke database oracle :RYANORA
Tidak ada komentar:
Posting Komentar