Syehaji93

update select error

Aug 4th, 2020
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.54 KB | None | 0 0
  1. Try
  2.            
  3.             Dim dtcmd1 As SQLiteDataAdapter = New SQLiteDataAdapter("Select tNik from tShift1 where tNik = (Select nik from tbESD_Tester where Tanggal = '2020-03-10')", SQLiteCon)
  4.             Dim ds As New DataSet
  5.             dtcmd1.Fill(ds)
  6.             SQLiteCon.Dispose()
  7.             SQLiteCon = Nothing
  8.             If ds.Tables.Count > 0 Then
  9.                 If ds.Tables(0).Rows.Count > 0 Then
  10.                     Dim cmd As SQLiteCommand = New SQLiteCommand("Insert into tShift1 (tNik, tNama, tDivisi, tSelasa, tTanggal, tShift) SELECT NIK, Nama, Divisi, Status, Tanggal, Shift FROM tbESD_Tester WHERE Tanggal = '2020-03-10' and shift = '1' ", SQLiteCon)
  11.                     cmd.ExecuteNonQuery()
  12.                     MsgBox("Success", MsgBoxStyle.Information, "Add new data success")
  13.                 Else
  14.                         Dim cmd As SQLiteCommand = New SQLiteCommand("UPDATE tShift1 SET tSelasa = (SELECT Status FROM tbESD_Tester WHERE Tanggal = '2020-03-10' and strftime('%w', Tanggal) = '2' and tbESD_Tester.NIK = tShift1.tNIK), tTanggal = (SELECT Tanggal FROM tbESD_Tester WHERE Tanggal = '2020-03-10' and strftime('%w', Tanggal) = '2' and tbESD_Tester.NIK = tShift1.tNIK) WHERE EXISTS(SELECT * FROM tbESD_Tester WHERE tbESD_Tester.NIK = tShift1.tNIK)", SQLiteCon)
  15.                         cmd.ExecuteNonQuery()
  16.                         MsgBox("Success", MsgBoxStyle.Information, "Add new data success")
  17.                 End If
  18.             End If
  19.         Catch ex As Exception
  20.             MsgBox(ex.Message)
  21.         End Try
Advertisement
Add Comment
Please, Sign In to add comment