Jumat, 18 November 2011

Latihan 27


Public Class Latihan27_46109060
Dim conect As New OleDb.OleDbConnection("provider = microsoft.ace.oledb.12.0;data source=" & Application.StartupPath & "\databarang.accdb;jet OLEDB:database password=060")
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Val(t146109060.Text) = 0 Then
MsgBox("kode barang belum terisi")
Exit Sub
End If
If t246109060.Text.Length = 0 Then
MsgBox("nama barang belum terisi")
Exit Sub
End If
If Val(t346109060.Text) = 0 Then
MsgBox("harga jual belum diisi")
Exit Sub
End If
If Val(t446109060.Text) = 0 Then
MsgBox("jumlah barang belum diisi")
Exit Sub
End If
Dim fadli As New OleDb.OleDbCommand
fadli = New OleDb.OleDbCommand("insert into BARANG (kodebarang, namabarang, hargajual, jumlahbarang) values ('" & t146109060.Text & "','" & t246109060.Text & "'," & Val(t346109060.Text) & "," & Val(t446109060.Text) & ")", conect)
conect.Open()
fadli.ExecuteNonQuery()
conect.Close()
fadli.Dispose()
t146109060.Text = ""
t246109060.Text = ""
t346109060.Text = ""
t446109060.Text = ""
End Sub
End Class

Tidak ada komentar:

Posting Komentar