Because SQLite is typeless, one can store anything in any column and it won't complain. So what was happening in my case was that someone had stored empty string in an INTEGER
type column. That's why my query was not updating those rows, even if they appeared similar to NULL cells. I have now added a check for empty string in my UPDATE
query. Hope this helps someone down the road.
SQLite INTEGER(11) column behaving strangely
Domanda
So this is a SQLite database and the column map_id
in table locations
is of type INTEGER(11)
. I try to update all instances where map_id
is 0
or -1
to NULL
:
UPDATE locations SET map_id = NULL WHERE map_id = 0 OR map_id = -1
I add this query to my strongly-typed DataSet in a QueriesTableAdapter
. I run this query and then fill my DataSet table locations
with the underlying database data, hoping that I won't see any 0
or -1
in map_id
column. Booo! I have some. I run the UPDATE query again and check the number of affected rows; it is zero. So no rows were affected by the UPDATE query, meaning there are no rows with map_id
0
or -1
. Yet I see them in the fetched DataTable
. What's going on here?
Soluzione
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow