# SQLite ignoring null on edit using the RowSet.EditRow method

**URL:** <https://forum.xojo.com/t/sqlite-ignoring-null-on-edit-using-the-rowset-editrow-method/81534>\
**Category:** Databases\
**Created:** [August 26, 2024, 10:02pm UTC](https://forum.xojo.com/t/sqlite-ignoring-null-on-edit-using-the-rowset-editrow-method/81534 "2024-08-26T22:02:30Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Keidel](https://forum.xojo.com/user_avatar/forum.xojo.com/john_keidel/32/7102_2.png) [@John\_Keidel](https://forum.xojo.com/u/John_Keidel)\
**Post date:** [August 26, 2024, 10:02pm UTC](https://forum.xojo.com/t/sqlite-ignoring-null-on-edit-using-the-rowset-editrow-method/81534/1 "2024-08-26T22:02:30Z")

</div>

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:

```auto
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:

```auto
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?

---

<div class="post-metadata">

**Author:** ![AlbertoD](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/dbc845/32.png) [@AlbertoD](https://forum.xojo.com/u/AlbertoD)\
**Post date:** [August 26, 2024, 10:17pm UTC](https://forum.xojo.com/t/sqlite-ignoring-null-on-edit-using-the-rowset-editrow-method/81534/2 "2024-08-26T22:17:49Z")

</div>

If StartDate is null, you may need to check for that and use

```auto
rs.Column("start_date").Value = Nil ' sets to NULL in the database

```

Note: no experience, just read the documentation here  
[https://documentation.xojo.com/api/databases/databasecolumn.html#databasecolumn-value](https://documentation.xojo.com/api/databases/databasecolumn.html#databasecolumn-value)

---

<div class="post-metadata">

**Author:** ![John\_Keidel](https://forum.xojo.com/user_avatar/forum.xojo.com/john_keidel/32/7102_2.png) [@John\_Keidel](https://forum.xojo.com/u/John_Keidel)\
**Post date:** [August 26, 2024, 10:38pm UTC](https://forum.xojo.com/t/sqlite-ignoring-null-on-edit-using-the-rowset-editrow-method/81534/3 "2024-08-26T22:38:00Z")

</div>

Thanks Alberto! That works!

I missed that when I originally read the documentation.

---

<div class="post-metadata">

**Author:** ![Jean-Yves\_Pochez](https://forum.xojo.com/user_avatar/forum.xojo.com/jean-yves_pochez/32/21769_2.png) [@Jean-Yves\_Pochez](https://forum.xojo.com/u/Jean-Yves_Pochez)\
**Post date:** [August 27, 2024, 8:34am UTC](https://forum.xojo.com/t/sqlite-ignoring-null-on-edit-using-the-rowset-editrow-method/81534/4 "2024-08-27T08:34:28Z")

</div>

just for the records, I found editrow having lots of weird problems along the years…  
making a string with your update statement is far easier and works all the time  
(except if you have to take sql injection into account…)

---

<div class="post-metadata">

**Author:** ![Tim\_Hare](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_hare/32/176_2.png) [@Tim\_Hare](https://forum.xojo.com/u/Tim_Hare)\
**Post date:** [August 27, 2024, 10:22am UTC](https://forum.xojo.com/t/sqlite-ignoring-null-on-edit-using-the-rowset-editrow-method/81534/5 "2024-08-27T10:22:40Z")

</div>

Databases in general treat NULL diferently from other values. That’s why I always set a column to NOT NULL and set a default value.

---

<div class="post-metadata">

**Author:** ![TimStreater](https://forum.xojo.com/user_avatar/forum.xojo.com/timstreater/32/586_2.png) [@TimStreater](https://forum.xojo.com/u/TimStreater)\
**Post date:** [August 27, 2024, 11:59am UTC](https://forum.xojo.com/t/sqlite-ignoring-null-on-edit-using-the-rowset-editrow-method/81534/6 "2024-08-27T11:59:24Z")

</div>

If you use API2 database methods you don’t need to worry about sql injection; the parameters are bound for you:

```auto
sql = "update students set firstname = ?1 where id = ?2"
db.ExecuteSQL (sql, "Jean-Yves", 27)

```

---

<div class="post-metadata">

**Author:** ![Jean-Yves\_Pochez](https://forum.xojo.com/user_avatar/forum.xojo.com/jean-yves_pochez/32/21769_2.png) [@Jean-Yves\_Pochez](https://forum.xojo.com/u/Jean-Yves_Pochez)\
**Post date:** [August 27, 2024, 12:40pm UTC](https://forum.xojo.com/t/sqlite-ignoring-null-on-edit-using-the-rowset-editrow-method/81534/7 "2024-08-27T12:40:44Z")

</div>

> [@Tim\_Hare](#):
>
> Databases in general treat NULL diferently from other values. That’s why I always set a column to NOT NULL and set a default value.

I find NULL very nice to see if a field has been entered by the user or not. I often use them.
