Hi all
I have multiple checkboxes to be used as the status of a certain order.
another words as the order is being processed the user will check the status and a date will be inserted into an access table.
Now my isue is when a checkbox is checked for the first time it inserts the date into the table but if the user unchecks it atomaticly updates the table with a null value with no errors. If the same checkbox gets checked again
or any othercheck box I get the error "Operation must use an updateable query".
Im puzzeled because if I use the same code to insert and also the same code to update does anyone know why it works the first time it is used but not the second time.
here is the Update Code.
Public Sub Update_Status()
Try
Dim db As New Connection
db.FilePath = FrmMain.DBCredentials.DBPath
db.PalavraPass = FrmMain.DBCredentials.Pass
db.connect()
Dim UpdatequeryString As String = "UPDATE Status_tbl SET " & Statustype & "= @1 WHERE CustomerID=" & customerID
Dim dbcmd As New OleDbCommand(UpdatequeryString, db.con)
db.con.Open()
With dbcmd.Parameters
If StatusDate.Year <> "1900" Then
.AddWithValue("@1", StatusDate)
Else
.AddWithValue("@1", DBNull.Value)
End If
End With
dbcmd.CommandType = CommandType.Text
dbcmd.CommandText = UpdatequeryString
dbcmd.ExecuteNonQuery()
db.con.Close()
Catch ex As Exception
MsgBox("STATUS.Update_Status: " & ex.Message)
End Try
End Sub