Created
October 27, 2017 15:28
-
-
Save vbcupu/c80a8a0cf1236d41800ed1b915f81e91 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'Fungsi untuk membuka koneksi | |
Public Function OpenConnection() | |
Set dbconn = New ADODB.Connection | |
dbconn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path + "\mahasiswa.mdb;Persist Security Info=False" | |
dbconn.CursorLocation = adUseClient | |
dbconn.Open | |
End Function | |
'Fungsi untuk membuat query yang menghasilkan recordset | |
Public Function bukaRs(Query As String, Record As Recordset) | |
Set Record = New ADODB.Recordset | |
Record.Open Query, dbconn, adOpenStatic, adLockReadOnly | |
End Function | |
'Procedure untuk mengisi Data Combo | |
Public Sub IsiDataSource(dcName As DataCombo, rsTemp As ADODB.Recordset, Query As String) | |
Set rs = New ADODB.Recordset | |
Set rs = dbconn.Execute(Query) | |
Set dcName.RowSource = rsTemp | |
dcName.BoundColumn = rsTemp.Fields(0).Name | |
dcName.ListField = rsTemp.Fields(1).Name | |
End Sub | |
'Procedure untuk menjalankan perintah query untuk simpan, update dan delete | |
Public Sub execCmd(Cmd As ADODB.Command, Query As String) | |
Dim num_Affected As Integer | |
Set Cmd = New ADODB.Command | |
Cmd.ActiveConnection = dbconn | |
Cmd.CommandText = Query | |
Cmd.CommandType = adCmdText | |
Cmd.CommandTimeout = 60 | |
Cmd.Execute num_Affected | |
If num_Affected = 0 Then | |
Call MsgBox("Transaksi Gagal") | |
Else | |
Call MsgBox("Transaksi Berhasil") | |
End If | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment