Import dan mengolah text document bag.1



Skenario:



  1. File di ambil dari JDE berupa file dengan extensi .txt

  2. mengosongkan table untuk menampung imports

  3. File di import ke acces sebagai databasenya

  4. File hasil import diolah

  5. Hasil olahan di export ke excel

Coding langkah 2 dengan judul form pengosongan tabel

Imports System.Data
Imports System.Data.OleDb


#Region "declare"
Dim mykoneksi As New acces.datacon
Dim objcommand As OleDbCommand
Dim objdataadapter As OleDbDataAdapter
Dim objdatatable As New DataTable
Dim objdataset As New DataSet
Dim strsql As String
#End Region


#Region "import"
Sub hapusimport()
Try
objcommand = New OleDbCommand("delete from [cost]")
objcommand.Connection = mykoneksi.open
objcommand.ExecuteNonQuery()
mykoneksi.close()
'MsgBox("Hapus tabel hasil import dari JDE sukses")
Catch ex As Exception
MsgBox("koneksi ke database gagal" & ex.Message)
End Try
End Sub
#End Region


#Region "proses"
Sub hapusproses()
Try
objcommand = New OleDbCommand("delete from [backcoast]")
objcommand.Connection = mykoneksi.open
objcommand.ExecuteNonQuery()
mykoneksi.close()
'MsgBox("Hapus tabel Proses Data dari JDE sukses")
Catch ex As Exception
MsgBox("koneksi ke database gagal" & ex.Message)
End Try
End Sub
#End Region


#Region "export"
Sub hapusexport()
Try
objcommand = New OleDbCommand("delete from [export]")
objcommand.Connection = mykoneksi.open
objcommand.ExecuteNonQuery()
mykoneksi.close()
'MsgBox("Hapus tabel Export Ke Excel sukses")
Catch ex As Exception
MsgBox("koneksi ke database gagal" & ex.Message)
End Try
End Sub
#End Region

Button Kosongkan diklik

hapusimport()
hapusproses()
hapusexport()

0 komentar: