Scrapt Project Part 1 - 3


Tombol Cari klik
#Region "cari"

Sub cari(ByVal cari As String, ByVal fil As String) objdatatable.Clear()
ListView1.Refresh()
ListView1.Items.Clear()
Try
objcommand = New OleDbCommand
("select * from [db_scrapt]where " & fil & " = '" & cari & "'")
objcommand.Connection = mykoneksi.open objdataadapter = New OleDbDataAdapter(objcommand)
objdataadapter.Fill(objdataset, "brand")
objdatatable = objdataset.Tables("brand")
objdatareaer = objcommand.ExecuteReader
For I = 0 To objdatatable.Rows.Count - 1
objdatareaer.Read()
Dim tgl As Date = CDate(objdatareaer.Item(4))
With ListView1.Items.Add(objdatareaer.Item(0))
.SubItems.Add(objdatareaer.Item(1))
.SubItems.Add(objdatareaer.Item(2))
.SubItems.Add(objdatareaer.Item(3))
.SubItems.Add(tgl.ToShortDateString)
.SubItems.Add(objdatareaer.Item(5))
.SubItems.Add(objdatareaer.Item(6))
.SubItems.Add(objdatareaer.Item(7))
.SubItems.Add(objdatareaer.Item(8))
.SubItems.Add(objdatareaer.Item(9))
.SubItems.Add(objdatareaer.Item(10))
.SubItems.Add(objdatareaer.Item(11))
.SubItems.Add(objdatareaer.Item(12))
.SubItems.Add(objdatareaer.Item(13))
.SubItems.Add(objdatareaer.Item(14))
End With
Next I
mykoneksi.close()
Catch ex As Exception
MsgBox("konek ke database gagal" & ex.Message)
mykoneksi.close()
End Try
End Sub
#End Region

Cari Berdasarkan Production Number

#Region "cariprod"
Sub cariprod(ByVal cari As String, ByVal fil As String)
objdatatable.Clear()
ListView1.Refresh()
ListView1.Items.Clear()
Try objcommand = New OleDbCommand
("select * from [db_scrapt]where " & fil & " like '%" & cari & "%'")
objcommand.Connection = mykoneksi.open
objdataadapter = New OleDbDataAdapter(objcommand)
objdataadapter.Fill(objdataset, "brand")
objdatatable = objdataset.Tables("brand")
objdatareaer = objcommand.ExecuteReader
For I = 0 To objdatatable.Rows.Count - 1
objdatareaer.Read()
Dim tgl As Date = CDate(objdatareaer.Item(4))
With ListView1.Items.Add(objdatareaer.Item(0))
.SubItems.Add(objdatareaer.Item(1))
.SubItems.Add(objdatareaer.Item(2))
.SubItems.Add(objdatareaer.Item(3))
.SubItems.Add(tgl.ToShortDateString)
.SubItems.Add(objdatareaer.Item(5))
.SubItems.Add(objdatareaer.Item(6))
.SubItems.Add(objdatareaer.Item(7))
.SubItems.Add(objdatareaer.Item(8))
.SubItems.Add(objdatareaer.Item(9))
.SubItems.Add(objdatareaer.Item(10))
.SubItems.Add(objdatareaer.Item(11))
.SubItems.Add(objdatareaer.Item(12))
.SubItems.Add(objdatareaer.Item(13))
.SubItems.Add(objdatareaer.Item(14))
End With Next I mykoneksi.close()
Catch ex As Exception
MsgBox("konek ke database gagal" & ex.Message)
mykoneksi.close()
End Try
End Sub
#End Region

#Region "contoh"
Sub contoh()
Try
objcommand = New OleDbCommand("select * from [db_scrapt] ")
objcommand.Connection = mykoneksi.open
objdataadapter = New OleDbDataAdapter(objcommand)
objdataadapter.Fill(objdataset, "brand")
objdatatable = objdataset.Tables("brand")
objdatareaer = objcommand.ExecuteReader
For I = 0 To objdatatable.Rows.Count - 1
objdatareaer.Read()
Dim tgl As Date = CDate(objdatareaer.Item(4))
With ListView1.Items.Add(objdatareaer.Item(0))
'.SubItems.Add(objdatareaer.Item(0))
.SubItems.Add(objdatareaer.Item(1))
.SubItems.Add(objdatareaer.Item(2))
.SubItems.Add(objdatareaer.Item(3))
.SubItems.Add(tgl.ToShortDateString)
.SubItems.Add(objdatareaer.Item(5))
.SubItems.Add(objdatareaer.Item(6))
.SubItems.Add(objdatareaer.Item(7))
.SubItems.Add(objdatareaer.Item(8))
.SubItems.Add(objdatareaer.Item(9))
.SubItems.Add(objdatareaer.Item(10))
.SubItems.Add(objdatareaer.Item(11))
.SubItems.Add(objdatareaer.Item(12))
.SubItems.Add(objdatareaer.Item(13))
.SubItems.Add(objdatareaer.Item(14))
End With
Next I
mykoneksi.close()
Catch ex As Exception
MsgBox("tidak dapat menampilkan data" & vbCrLf & ex.Message)
End Try
End Sub
#End Region

0 komentar: