Rating: 4.5
Reviewer: Unknown
ItemReviewed: Visual Basic Database
PROGRAM BERBASIS DATABASE
Membuat Program Berbasis Database (MS.ACCESS 2003)
Membuat Database di Ms. Access 2003
1.
Buatlah sebuah project dengan nama PdbMhs
di (drive D:\nama_anda)
2.
Buatlah database dengan menggunakan Ms.Access dengan format 2002-2003 dengan nama dbMhs simpan di (drive D:\nama_anda\PdbMhs\obj\Debug)
3.
Kemudian buat table dengan nama tbMhs
Field Name
|
Data Type
|
Keterangan
|
NIM
|
Text
|
FieldSize = 8
Primary Key
|
Nama
|
Text
|
FieldSize = 20
|
Alamat
|
Text
|
FieldSize
= 20
|
Telp
|
Text
|
FieldSize
= 15
|
4.
Isi minimal 5 record, bebas!
5.
Tutup Ms.Access
Membuat Program Aplikasi di Visual Basic .NET
1.
Buka Microsoft Visual Studio .NET.
2.
Klik menu View - Server Explorer.
3.
Di Server Explorer – klik kanan Data Connections - pilih Add Connection.
4.
Dalam kotak dialog Data Link Properties, klik
tab Provider.
5.
Dalam OLE DB
Provider(s) list - klik Microsoft Jet 4.0 OLE DB Provider - klik Next.
6.
Klik tab Connection, kemudian klik ellipses
button (...).
7.
Cari posisi file Access database dbMhs dalam komputer Anda.
8.
Pilih file dbMhs,
kemudian klik Open.
9.
Dalam kotak dialog Data Link Properties - OK.
10.
Dalam toolbox
– klik tab Data.
11.
Drag OleDbDataAdapter ke Form1.
12.
Dalam Data
Adapter Configuration Wizard - klik Next 3x.
13.
Di panel Generate the SQL statements, ketikan
coding di Microsoft SQL Server
Select * from tbMhs
14.
Kemudia klik Next – panel View Wizard Results - klik Finish.
Catatan : Dalam dialog box akan mucul : Do you want to include the password in the connection string? - pilih Don't include password.
Catatan : Dalam dialog box akan mucul : Do you want to include the password in the connection string? - pilih Don't include password.
15.
Klik kanan pada OleDbDataAdapter1 - klik Generate
Dataset.
16.
Di dialog box Generate Dataset - OK.
17.
Tambahkan coding pada event Form1_Load:
OleDbDataAdapter1.Fill(DataSet11)
Menampilkan record data
dari Database Ms. Access ke form di Visual Basic
1.
Tambahkan DataGrid ke Form1.
2.
Klik kanan DataGrid1 - klik Properties.
3.
Di Properties
atur sbb:
DataSource : DataSet11
DataMember : tbMhs
Menambahkan
record baru pada Database Access
1.
Tambah Button ke Form1 atur properties sebagai berikut :
Text : Add
Name : btAdd
2.
Klik 2x pada button Add kemudian ketikan coding sbb:
Dim i, NIM As Integer
Dim
Nama,Alamat,Telp As String
Dim rw As DataRow
'menambahkan
record pada table tbMHS
rw = DataSet11.Tables(0).NewRow
NIM = InputBox("Ketikan NIM:")
Nama = InputBox("Ketikan Nama:")
Alamat = InputBox("Ketikan Alamat:")
Telp =
InputBox("Ketikan Telp:")
rw.Item("NIM") = NIM
rw.Item("Nama") = Nama
rw.Item("Alamat") = Alamat
rw.Item("Telp") = Telp
Try
DataSet11.Tables(0).Rows.Add(rw)
'Update
the Student table in the testdb database.
i =
OleDbDataAdapter1.Update(DataSet11)
Catch
ex As Exception
MessageBox.Show(ex.Message)
End Try
'Displays
number of rows updated.
MessageBox.Show("no of rows
updated=" & i)
Script Tambahan Visual Basic
Loading
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Start()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim Login As New FrmLogin
Dim ProgressBar As New Form1
If ProgressBar1.Value < 100 Then
ProgressBar1.Value += 2
ElseIf ProgressBar1.Value = 100 Then
Timer1.Stop()
MessageBox.Show("Ujian Akhir Semester Visual Basic: Denny Cahyana !", "Pemberitahuan", MessageBoxButtons.OK, MessageBoxIcon.Information)
Login.Show()
End If
End Sub
Login
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btLogin.Click
Dim Menu As New FrmMenu
If txtusername.Text = "denny" And txtpassword.Text = "tuktik" Then
Menu.Show()
Else
MsgBox("Username atau Password yang anda masukan salah !", MsgBoxStyle.Critical)
End If
End Sub
CheckedListBox
Clear
For i As Integer = 0 To clbJabatan.Items.Count - 1
clbJabatan.SetItemChecked(i, False)
Next
Get Checked
For Each itemChecked In clbJabatan.CheckedItems
Next
Dim a As Integer
For a = 0 To clbJabatan.CheckedItems.Count - 1
Jabatan = clbJabatan.CheckedItems.Item(a)
Next
Login
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btLogin.Click
Dim Menu As New FrmMenu
If txtusername.Text = "denny" And txtpassword.Text = "tuktik" Then
Menu.Show()
Else
MsgBox("Username atau Password yang anda masukan salah !", MsgBoxStyle.Critical)
End If
End Sub
CheckedListBox
Clear
For i As Integer = 0 To clbJabatan.Items.Count - 1
clbJabatan.SetItemChecked(i, False)
Next
Get Checked
For Each itemChecked In clbJabatan.CheckedItems
Next
Dim a As Integer
For a = 0 To clbJabatan.CheckedItems.Count - 1
Jabatan = clbJabatan.CheckedItems.Item(a)
Next