Anda di halaman 1dari 3

Imports System.Data.

OleDb
Public Class Form1
Dim con As OleDbConnection
Dim com As OleDbCommand
Dim red As OleDbDataReader
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.Eve
ntArgs) Handles Timer1.Tick
a.Text = Format(TimeOfDay)
b.Text = Format(Today)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.Even
tArgs) Handles MyBase.Load
Timer1.Enabled = True
con = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data source
=rec.accdb")
con.Open()
com = New OleDbCommand("Select * from rec", con)
red = com.ExecuteReader
red.Read()
While red.Read = True
Dim a As ListViewItem
a = ListView1.Items.Add(red("dep"))
a.SubItems.Add(red("amount"))
a.SubItems.Add(red("track"))
a.SubItems.Add(red("mdate"))
End While
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.E
ventArgs) Handles Button1.Click
Dim done As New OleDbCommand
done.Connection = con
done.CommandText = "INSERT INTO rec (dep,amount,track,mdate) values (@a,
@b,@c,@d)"
done.Parameters.Add(New
done.Parameters.Add(New
done.Parameters.Add(New
done.Parameters.Add(New

OleDbParameter("@a",
OleDbParameter("@b",
OleDbParameter("@c",
OleDbParameter("@d",

OleDbType.VarChar,
OleDbType.VarChar,
OleDbType.VarChar,
OleDbType.VarChar,

done.Prepare()
done.Parameters("@a").Value
done.Parameters("@b").Value
done.Parameters("@c").Value
done.Parameters("@d").Value

=
=
=
=

TextBox1.Text
TextBox2.Text
TextBox3.Text
b.Text

done.ExecuteNonQuery()
MsgBox("Done")
ListView1.Items.Clear()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
com = New OleDbCommand("Select * from rec", con)
red = com.ExecuteReader
red.Read()

50))
50))
50))
50))

While red.Read = True


Dim a As ListViewItem
a = ListView1.Items.Add(red("dep"))
a.SubItems.Add(red("amount"))
a.SubItems.Add(red("track"))
a.SubItems.Add(red("mdate"))
End While
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.E
ventArgs) Handles Button3.Click
If TextBox8.Text = "" Then
MsgBox("No data to search.")
Else
Dim sear As New OleDbCommand
sear = New OleDbCommand("Select * from rec WHERE track='" & TextBox8
.Text & "'", con)
red.Close()
red = sear.ExecuteReader
ListView1.Items.Clear()
While red.Read = True
Dim a As ListViewItem
a = ListView1.Items.Add(red("dep"))
a.SubItems.Add(red("amount"))
a.SubItems.Add(red("track"))
a.SubItems.Add(red("mdate"))
TextBox4.Text
TextBox5.Text
TextBox6.Text
TextBox7.Text
End While
End If

=
=
=
=

(red("dep"))
(red("amount"))
(red("track"))
(red("mdate"))

End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.E
ventArgs) Handles Button2.Click
If TextBox6.Text = "" Or TextBox8.Text = "" Then
MsgBox("Tracking No. is Empty.")
Else
Dim del As New OleDbCommand
del.Connection = con
del.CommandText = "DELETE FROM rec WHERE track='" & TextBox6.Text &
"'"
del.ExecuteNonQuery()
MsgBox("Claimed.")
ListView1.Items.Clear()
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
TextBox8.Text = ""
While red.Read = True
Dim a As ListViewItem
a = ListView1.Items.Add(red("dep"))
a.SubItems.Add(red("amount"))
a.SubItems.Add(red("track"))
a.SubItems.Add(red("mdate"))

End While
End If
End Sub
End Class