Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Try
- Dim dtcmd1 As SQLiteDataAdapter = New SQLiteDataAdapter("Select tNik from tShift1 where tNik = (Select nik from tbESD_Tester where Tanggal = '2020-03-10')", SQLiteCon)
- Dim ds As New DataSet
- dtcmd1.Fill(ds)
- SQLiteCon.Dispose()
- SQLiteCon = Nothing
- If ds.Tables.Count > 0 Then
- If ds.Tables(0).Rows.Count > 0 Then
- 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)
- cmd.ExecuteNonQuery()
- MsgBox("Success", MsgBoxStyle.Information, "Add new data success")
- Else
- 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)
- cmd.ExecuteNonQuery()
- MsgBox("Success", MsgBoxStyle.Information, "Add new data success")
- End If
- End If
- Catch ex As Exception
- MsgBox(ex.Message)
- End Try
Advertisement
Add Comment
Please, Sign In to add comment