First here's my code:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
'Variables
Dim PatientNo As Integer = CInt(ID_TextBox.Text)
Dim updatedDate As DateTime = DateTimePicker1.Value
dbcon.Open()
'If Selected "Cleared"
If ComboBox1.SelectedIndex = 0 Then
query = "UPDATE Swab SET isActive = FALSE, NextSwab = NULL WHERE PatientNo = " & PatientNo & ""
Dim cmd As OleDbCommand = New OleDbCommand(query, dbcon)
Dim dbada As New OleDbDataAdapter(cmd)
'If Selected "Positive"
ElseIf ComboBox1.SelectedIndex = 1 Then
updatedDate = updatedDate.AddDays(7)
query = "UPDATE Swab SET DateOfSpecimenCollection = " & DateTimePicker1.Value & ", NextSwab = " & updatedDate & " WHERE PatientNo = " & PatientNo & ""
Dim cmd As OleDbCommand = New OleDbCommand(query, dbcon)
Dim dbada As New OleDbDataAdapter(cmd)
End If
dbcon.Close()
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub
Note: The AutoID is the PatientNo
I want to create a program that will update a value in a ms-access database using PatientNo ID to identify what record should be updated. If I choose index 0, it will update isActive to False and make the date NextSwab to NULL or blank.
However if i choose 1, it will update DateOfSpecimenCollection based on date and time picked in the vb program and NextSwab based on DateTime picked + 7 days.
The problem with my code, for some reason it returns nothing. It didn't get errors but it doesn't return the values that i want in my database either. I tried using the ExecuteNonQuery() before but it doesn't work either. Need help I'm a beginner and trying to learn vb.net with MS Access, thank you.
