Sub Navigator()
Try
Dim NIK, RoleID, RoleName, Nama As String
Dim FullName, FullRole As String
Dim i As Integer
strSQL = "SELECT Users.NIK, Karyawan.FirstName, Role.RoleID, " & _
" Role.RoleName, Users.Password" & _
" FROM Role INNER JOIN (Karyawan INNER JOIN Users ON Karyawan.NIK = Users.NIK) " & _
" ON Role.RoleID = Users.RoleID Order by Users.Nik asc;"
objCommand = New OleDbCommand
objCommand.Connection = MyConnection.open
objCommand.CommandType = CommandType.Text
objCommand.CommandText = strSQL
objDataAdapter = New OleDbDataAdapter(objCommand)
objDataAdapter.Fill(objDataSet, "MDT_Users")
MyConnection.close()
objDataTable = objDataSet.Tables("MDT_Users")
mPosition = BindingContext(objDataTable).Position
With objDataTable.Rows(mPosition)
NIK = .Item("NIK")
Nama = .Item("FirstName").ToString
RoleID = .Item("RoleID").ToString
RoleName = .Item("RoleName").ToString
txtPassword.Text = .Item("Password").ToString
End With
FullName = NIK & " - " & Nama
FullRole = RoleID & " - " & RoleName
For i = 0 To (cbNama.Items.Count - 1)
If FullName = cbNama.Items.Item(i).ToString() Then
cbNama.SelectedIndex = i
Exit For
End If
Next i
For i = 0 To (cbRole.Items.Count - 1)
If FullRole = cbRole.Items.Item(i).ToString() Then
cbRole.SelectedIndex = i
Exit For
End If
Next i
NIK = Nothing
RoleID = Nothing
RoleName = Nothing
Nama = Nothing
FullName = Nothing
FullRole = Nothing
Catch When Err.Number <> 0
MsgBox("Tidak dapat membuat hubungan ke database" _
& vbCrLf & Err.Description)
MyConnection.close()
End Try
End Sub
Try
Dim NIK, RoleID, RoleName, Nama As String
Dim FullName, FullRole As String
Dim i As Integer
strSQL = "SELECT Users.NIK, Karyawan.FirstName, Role.RoleID, " & _
" Role.RoleName, Users.Password" & _
" FROM Role INNER JOIN (Karyawan INNER JOIN Users ON Karyawan.NIK = Users.NIK) " & _
" ON Role.RoleID = Users.RoleID Order by Users.Nik asc;"
objCommand = New OleDbCommand
objCommand.Connection = MyConnection.open
objCommand.CommandType = CommandType.Text
objCommand.CommandText = strSQL
objDataAdapter = New OleDbDataAdapter(objCommand)
objDataAdapter.Fill(objDataSet, "MDT_Users")
MyConnection.close()
objDataTable = objDataSet.Tables("MDT_Users")
mPosition = BindingContext(objDataTable).Position
With objDataTable.Rows(mPosition)
NIK = .Item("NIK")
Nama = .Item("FirstName").ToString
RoleID = .Item("RoleID").ToString
RoleName = .Item("RoleName").ToString
txtPassword.Text = .Item("Password").ToString
End With
FullName = NIK & " - " & Nama
FullRole = RoleID & " - " & RoleName
For i = 0 To (cbNama.Items.Count - 1)
If FullName = cbNama.Items.Item(i).ToString() Then
cbNama.SelectedIndex = i
Exit For
End If
Next i
For i = 0 To (cbRole.Items.Count - 1)
If FullRole = cbRole.Items.Item(i).ToString() Then
cbRole.SelectedIndex = i
Exit For
End If
Next i
NIK = Nothing
RoleID = Nothing
RoleName = Nothing
Nama = Nothing
FullName = Nothing
FullRole = Nothing
Catch When Err.Number <> 0
MsgBox("Tidak dapat membuat hubungan ke database" _
& vbCrLf & Err.Description)
MyConnection.close()
End Try
End Sub