Selasa, 14 Agustus 2012
Pembuatan Data Menggunakan Oracle Form
Imports System.Data.OracleClient
Public Class Form1
Dim xCon As New OracleConnection
Dim xComm As New OracleCommand
Dim dr As OracleDataReader
Dim da As OracleDataAdapter
Dim ds As New DataSet
Sub tampil()
xComm.CommandText = "select * from perpustakaan"
da = New OracleDataAdapter(xComm.CommandText, xCon)
da.Fill(ds, "uci")
DataGrid1.DataSource = ds.Tables("uci").DefaultView
End Sub
Sub baca()
xComm.CommandText = "select * from perpustakaan where no like '" & TextBox1.Text & "%'"
xComm.Connection = xCon
dr = xComm.ExecuteReader
If dr.HasRows Then
While dr.Read
TextBox1.Text = dr.Item(0)
TextBox2.Text = dr.Item(1)
TextBox3.Text = dr.Item(2)
TextBox4.Text = dr.Item(3)
TextBox5.Text = dr.Item(4)
TextBox6.Text = dr.Item(5)
End While
dr.Close()
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
xCon.ConnectionString = "Data Source=(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = Iccuz_Cappiccuz)(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = XE))); user id=uci; password=uci"
xCon.Open()
tampil()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
xComm.CommandText = "insert into perpustakaan values(" & _
"'" & TextBox1.Text & "'" & _
",'" & TextBox2.Text & "'" & _
",'" & TextBox3.Text & "'" & _
",'" & TextBox4.Text & "'" & _
",'" & TextBox5.Text & "'" & _
",'" & TextBox6.Text & "')"
xComm.Connection = xCon
xComm.ExecuteNonQuery()
da = New OracleDataAdapter(xComm.CommandText, xCon)
da.Fill(ds, "uci")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
xComm.CommandText = " Update perpustakaan SET " & _
"pengarang='" & TextBox4.Text & "'" & _
"WHERE no like'" & TextBox1.Text & "'"
xComm.Connection = xCon
xComm.ExecuteNonQuery()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
xComm.CommandText = " Delete perpustakaan " & _
"WHERE no like'" & TextBox1.Text & "'"
xComm.Connection = xCon
xComm.ExecuteNonQuery()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
baca()
End Sub
End Class
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar