Advertisement
Syehaji93

cek data is exist

Jul 25th, 2020
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.16 KB | None | 0 0
  1. Sub pindah_data()
  2.         Dim SQLiteCon As New SQLiteConnection(DB_Path)
  3.  
  4.         Try
  5.             SQLiteCon.Open()
  6.         Catch ex As Exception
  7.             SQLiteCon.Dispose()
  8.             SQLiteCon = Nothing
  9.             MsgBox(ex.Message)
  10.             Exit Sub
  11.         End Try
  12.  
  13.         Try
  14.             Dim sql1 As String = "Select tNik from tbTester where tanggal = '2020-03-09' "
  15.             Dim cmd1 As SQLiteCommand = New SQLiteCommand(sql1, SQLiteCon)
  16.  
  17.             Using reader As SQLiteDataReader = cmd1.ExecuteReader()
  18.                 If reader.HasRows Then
  19.                     MsgBox("User already exist", MsgBoxStyle.Exclamation, "add new data.!")
  20.                 Else
  21.                     Dim cmd As SQLiteCommand = New SQLiteCommand("Insert tS1 (tNik, tNama, tDivisi, tSenin, tTanggal, tShift) SELECT NIK, Nama, Divisi, Status, Tanggal, Shift FROM tbESD_Tester WHERE Tanggal = '2020-03-09' and shift = '1' ", SQLiteCon)
  22.                     cmd.ExecuteNonQuery()
  23.                     MsgBox("Success", MsgBoxStyle.Information, "Add new data success")
  24.                 End If
  25.             End Using
  26.         Catch ex As Exception
  27.  
  28.         End Try
  29.     End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement