Hello!
Kali ini saya akan memposting tugas LAB SMBD saya tentang Stored Procedure dan Trigger.
Saya menggunakan contoh kasus rumah sakit untuk kali ini.
1. Table
2. Design
3. Coding
Imports System.Data
Imports System.Data.OleDb
Public Class datapasien
Inherits System.Web.UI.Page
Public constring As String = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
Public oConn As New OleDbConnection(constring)
Public oTbl As New DataTable
Public xReader As OleDbDataReader
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
'Insert
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim sql As String = "INSERT INTO TablePasien VALUES ('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "')"
Dim oCmd As New OleDbCommand
oConn.Open()
oCmd.Connection = oConn
oCmd.CommandText = sql
oCmd.ExecuteNonQuery()
End Sub
Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Response.Redirect("View.aspx")
End Sub
'Search
Protected Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
oConn.Close()
oConn.Open()
Dim Cmd As New OleDbCommand("SELECT * FROM TablePasien where IDPasien =" + TextBox1.Text + "", oConn)
xReader = Cmd.ExecuteReader
If xReader.HasRows Then
xReader.Read()
TextBox2.Text = xReader("Waktu Kunjungan")
TextBox3.Text = xReader("Keluhan")
TextBox4.Text = xReader("Dokter yang menangani")
TextBox5.Text = xReader("Tindakan")
Else
MsgBox("ID Pasien Tidak Ada")
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
Exit Sub
End If
xReader.Close()
End Sub
'Update
Protected Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Dim sql As String = " UPDATE TablePasien set Waktu Kunjungan ='" & TextBox2.Text & "', Keluhan = '" & TextBox3.Text & "', Dokter yang menangani = '" & TextBox4.Text & "', Tindakan = '" & TextBox5.Text & "' where IDPasien = " & TextBox1.Text & ""
Dim oCmd As New OleDbCommand
oConn.Close()
oConn.Open()
oCmd.Connection = oConn
oCmd.CommandText = sql
oCmd.ExecuteNonQuery()
End Sub
End Class
Demikian Tugas UAS LAB SMBD saya, terima kasih!
Elizabeth Clara Sukma
1506761141
Jumat, 26 Mei 2017
Kamis, 06 April 2017
NORMALISASI DATABASE PEMINJAMAN BUKU
Saat ini saya akan melakukan normalisasi pada database peminjaman buku di sebuah perusahaan
TableBuku (IDBuku, JudulBuku, TglTerbit, IDPenerbit)
TablePenerbt (IDPenerbit, NamaPenerbit, AlamatPenerbit)
TablePeminjam (IDPeminjam, NamaPeminjam, AlamatPeminjam)
Tahapan Normalisasi
- 1NF
- 2NF
TableBuku (IDBuku, JudulBuku, TglTerbit, IDPenerbit)
TablePenerbt (IDPenerbit, NamaPenerbit, AlamatPenerbit)
TablePeminjam (IDPeminjam, NamaPeminjam, AlamatPeminjam)
- 3NF sama dengan 2NF
Tampilan Tabel dan Web Form
Source Code
Source Code
Imports System.Data
Imports System.Data.OleDb
Public Class WebForm2
Inherits System.Web.UI.Page
Public constring As String = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
Public oConn As New OleDbConnection(constring)
Public oTbl As New DataTable
Public xReader As OleDbDataReader
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim sql As String = "INSERT INTO TABLEPEMINJAMAN VALUES ('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "')"
Dim oCmd As New OleDbCommand
oConn.Open()
oCmd.Connection = oConn
oCmd.CommandText = sql
oCmd.ExecuteNonQuery()
End Sub
Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Response.Redirect("WebForm1.aspx")
End Sub
Protected Sub Button4_Click(sender As Object, e As EventArgs) Handles Button3.Click
oConn.Close()
oConn.Open()
Dim Cmd As New OleDbCommand("SELECT * FROM TABLEPEMINJAMAN where IDBuku =" + TextBox1.Text + "", oConn)
xReader = Cmd.ExecuteReader
If xReader.HasRows Then
xReader.Read()
TextBox2.Text = xReader("IDPenerbit")
TextBox3.Text = xReader("IDPeminjam")
TextBox4.Text = xReader("JudulBuku")
TextBox5.Text = xReader("TglPeminjaman")
Else
MsgBox("Kode Buku Tidak Ada")
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
Exit Sub
End If
xReader.Close()
End Sub
Protected Sub Button3_Click(sender As Object, e As EventArgs) Handles Button4.Click
Dim hapus = MsgBox("Konfirmasi", MsgBoxStyle.YesNo, "Hapus")
If hapus = vbYes Then
oConn.Close()
oConn.Open()
Dim delet As String = "DELETE FROM TABLEPEMINJAMAN where IDBuku =" + TextBox1.Text + ""
Dim oCmd As New OleDbCommand
oConn.Close()
oConn.Open()
oCmd.Connection = oConn
oCmd.CommandText = delet
oCmd.ExecuteNonQuery()
MsgBox("Sudah terhapus", vbArchive)
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
End If
End Sub
Protected Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
Dim sql As String = " UPDATE TABLEPENYIMPANAN set IDPenerbit ='" & TextBox2.Text & "', IDPeminjam = " & TextBox3.Text & ", JudulBuku = '" & TextBox4.Text & ", TglPeminjaman = '" & TextBox5.Text & "' where IDBuku = " & TextBox1.Text & ""
Dim oCmd As New OleDbCommand
oConn.Close()
oConn.Open()
oCmd.Connection = oConn
oCmd.CommandText = sql
oCmd.ExecuteNonQuery()
End Sub
End Class
Langganan:
Postingan (Atom)