Your SlideShare is downloading. ×
  • Like
MEMBUAT DATABASE MYSQL
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply
Published

 

Published in Education
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
1,703
On SlideShare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
78
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. MEMBUAT DATABASE MYSQL Sebelum mendesain Database, terlebih duli kita mencari apa yang mau diambil uktuk data yang digunakan dalam Database. Sebagai contoh, mari kita ambil sebuah data yang selalu kita gunakan dalam setiap proses pada sebuah daftar: No Nip Nama Golongan Gaji Pokok Tunjangan Gaji Bersih 1 3234 KAMARUDDIN IV/a 30090000 Dari daftar diatas kita buatlah sebuah database MYSQL sebagai berikut : 1. Pastikan ada sistem yang dibutuhkan seperti: -Visual Studio 2005 -PHP Xampp -Master MySQL 2. Jalankan Xampp dan aktifkan Apache serta MySQL 3. Jalankan Internet Explorer lalu berikan intruksi http://localhost Maka tampil gambar berikut ini: phpMyAdmin 4. Klik PhpMyAdmin di pilihan Tools sebelah kiri sehingga muncul seperti di bawah ini: 5. Ketik nama Database pada Kotak Create New Database (pegawai)lalu pilih Create sehingga muncul gambar : Munar, ST = =Dosen FIKOM UmuslimMatangglumpangdua==
  • 2. 6. Ketik nama Tabel pada Kotak Create New Table on Database(tbpegawai)Dan jumlah Field (data) pada kotak Number of fields lalu klik Go sehingga tampil lah gambar berikut untuk pengisian fields database: 7. Ketiklah Field-Field seperti dibawah ini sampai selesai: 8. Lalu klick Save Munar, ST = =Dosen FIKOM UmuslimMatangglumpangdua==
  • 3. MENGAKTIFKAN/MEMBUAT KONEKSI DATABASE 1 MembuatKoneksi ODBC Sebelummelakukanpengolahan database MySQL diperlukanbeberapahalsebagaipersiapanawaldiantara nyaadalahmembuat ODBC sebagaisaranauntukdapatmengakses database. Cara membuat ODBC adalahsebagaiberikut. 1. 2. 3. 3. 4. 5. 6. 7. Klik menu Start Pilih Control Panel System and Security Pilih Administrative Tools Pilih Data Sources (ODBC) PilihTab User DSN Klik Add Pilih MySQL ODBC 3.51 Driver 8. 9. 10. 11. Gambar9.4 Memilih driver Klik Finish Tulis Data Soerce name (Misalnyapegawai) Pilih/klik database (Misalnyapegawai) Klik OK Gambar9.5 Konfigurasi ODBC 12. KlikpilihanTest 13. Klik OK 14. Klik OK sampaitutupsemuakotak dialog. Munar, ST = =Dosen FIKOM UmuslimMatangglumpangdua==
  • 4. Desain Form VB.Net Lable1 Lable2,…,Lable7 Textbox1.text Textbox2.text Combobox1.text Textbox3.text Textbox4.text Textbox5.text Buttom1,…,Buttom4 DataGridView Listing Program : Imports System.Data Imports System.Data.OleDb PublicClass Form1 Dim Conn As Odbc.OdbcConnection Dim da As Odbc.OdbcDataAdapter Dim ds As DataSet Dim str, tabel AsString Dim intRecordsAffected, a AsInteger Munar, ST = =Dosen FIKOM UmuslimMatangglumpangdua==
  • 5. Sub Koneksi() str = "Driver={MySQL ODBC 3.51 Driver};database=Pegawai;server=localhost;UID=root" Conn = New Odbc.OdbcConnection(str) If Conn.State = ConnectionState.Closed Then Conn.Open() EndIf EndSub Sub tampil() da = New Odbc.OdbcDataAdapter("Select * from tbpegawai", Conn) ds = New DataSet ds.Clear() da.Fill(ds, "tbpegawai") DGPeg.DataSource = (ds.Tables("tbpegawai")) EndSub PrivateSub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load Koneksi() tampil() EndSub PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If TextBox1.Text <>""And a = 0 Then tabel = "INSERT tbpegawai(nip,nama,gol,gapok,tunj,gaber)" + _ "VALUES('"& TextBox1.Text &"','"& TextBox2.Text &"','"& ComboBox1.Text &"','"& TextBox3.Text &"','"& TextBox4.Text &"','"& TextBox5.Text &"')" Dim cmdUpdates As Odbc.OdbcCommand = New Odbc.OdbcCommand(tabel, Conn) cmdUpdates.CommandType = CommandType.Text intRecordsAffected = cmdUpdates.ExecuteNonQuery a = 1 tampil() ElseIf TextBox1.Text = ""Then TextBox1.Focus() Else MsgBox("Data Telah Ada") EndIf EndSub PrivateSub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click tabel = "UPDATE tbpegawai set nama='"& TextBox2.Text &"',gol='"& ComboBox1.Text &"',gapok='"& TextBox3.Text &"',tunj='"& TextBox4.Text &"',gaber='"& TextBox5.Text &"' where nip='"& TextBox1.Text &"'" Dim cmdUpdates As Odbc.OdbcCommand = New Odbc.OdbcCommand(tabel, Conn) cmdUpdates.CommandType = CommandType.Text intRecordsAffected = cmdUpdates.ExecuteNonQuery tampil() EndSub Munar, ST = =Dosen FIKOM UmuslimMatangglumpangdua==
  • 6. PrivateSub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click tabel = "DELETE from tbpegawai where nip='"& TextBox1.Text &"'" Dim cmdUpdates As Odbc.OdbcCommand = New Odbc.OdbcCommand(tabel, Conn) cmdUpdates.CommandType = CommandType.Text intRecordsAffected = cmdUpdates.ExecuteNonQuery a = 0 tampil() EndSub PrivateSub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click End EndSub PrivateSub TextBox1_KeyPress(ByVal sender AsObject, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress If e.KeyChar = Chr(13) Then cari() EndIf EndSub Sub cari() da = New Odbc.OdbcDataAdapter("Select * from tbpegawai where nip='"& TextBox1.Text &"'", Conn) ds = New DataSet ds.Clear() da.Fill(ds, "tbpegawai") If da.Fill(ds, "tbpegawai") = FalseThen kosong() TextBox2.Focus() Else Dim tb As DataTable = ds.Tables(0) TextBox2.Text = tb.Rows(0)(1) ComboBox1.Text = tb.Rows(0)(2) TextBox3.Text = tb.Rows(0)(3) TextBox4.Text = tb.Rows(0)(4) TextBox5.Text = tb.Rows(0)(5) a = 1 EndIf EndSub Sub kosong() TextBox2.Text = "" ComboBox1.Text = "" TextBox3.Text = "" TextBox4.Text = "" TextBox5.Text = "" a = 0 EndSub Munar, ST = =Dosen FIKOM UmuslimMatangglumpangdua==
  • 7. PrivateSub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click da = New Odbc.OdbcDataAdapter("Select * from tbpegawai where nip='" + TextBox1.Text + "'", Conn) ds = New DataSet ds.Clear() da.Fill(ds, "tbpegawai") DGPeg.DataSource = (ds.Tables("tbpegawai")) EndSub PrivateSub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click kosong() TextBox1.Text = "" TextBox1.Focus() tampil() EndSub PrivateSub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged If TextBox1.Text = ""Then kosong() EndIf EndSub EndClass Hasilnya Munar, ST = =Dosen FIKOM UmuslimMatangglumpangdua==
  • 8. OptionStrictOn Imports System.Data Imports System.Data.Odbc Imports System.Data.SqlClient PublicClass TmpLaporan Dim Conn As Odbc.OdbcConnection Dim da As Odbc.OdbcDataAdapter Dim ds As DataSet Dim str AsString Dim rpt AsNew Laporan Sub Koneksi() str = "Driver={MySQL ODBC 3.51 Driver};database=Pegawai;server=localhost;UID=root" Conn = New Odbc.OdbcConnection(str) If Conn.State = ConnectionState.Closed Then Conn.Open() EndIf EndSub Sub Baca() da = New Odbc.OdbcDataAdapter("Select * from tbpegawai", Conn) ds = New DataSet ds.Clear() da.Fill(ds, "tbpegawai") CrystalReportViewer1.ReportSource = rpt EndSub PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Baca() EndSub PrivateSub TmpLaporan_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load Koneksi() EndSub EndClass Munar, ST = =Dosen FIKOM UmuslimMatangglumpangdua==