I am using a SQLite Database with a Windows Desktop Application.
I have following code is inside a Method with the Parameters: RecID As Integer, StartDate As DateTime:
Var rs As RowSet
Var sql As String = "SELECT * FROM tbl_employee WHERE id =" + RecID.ToString
Try
rs = self.SelectSQL(sql)
rs.EditRow
rs.Column("start_date").DateTimeValue = StartDate
rs.SaveRow
rs.Close
Catch error As DatabaseException
MessageBox("DB Error: " + error.Message)
End Try
The Method works fine when the StartDate parameter is Not Null. However, when the StartDate parameter is Null and it is replacing a non-null value in the database, the update is ignored with no errors and the edit remains unchanged.
Executing the following SQL statement does work with no problems with the same database:
UPDATE tbl_employee SET start_date = NULL WHERE id = " + RecID.ToString
However, having to write a separate procedure for every variable that is null seems so clumsy and laborious, especially when there are several variables or columns to update.
Does anyone have a solution or workaround where I can use the EditRow method to update a database when the values are Null?