R
Richard Kucia
I'm playing around with SQL CE for the first time, and it didn't take long
for me to come up with a puzzle. I created a little test app that gives the
user 3 buttons: Create, Insert and Display. "Create" deletes the SQL CE
database file (if it exists) and then creates a empty database with one
empty table named Books. "Insert" opens a connection to the DB, inserts 3
rows into the table "Books", and closes the connection. "Display" opens a
connection to the DB, populates a DataSet off a DataAdapter, sets a grid's
DataSource to the DataSet's "Books" table, and closes the connection. No
mystery here -- all ordinary stuff.
If I perform the following sequence, I see 6 rows in the grid, not 3.
(a) Create (creates an empty database with one table "Books" and zero rows)
(b) Insert (inserts 3 rows into "Books")
(c) Display (shows 3 rows)
(d) Create (same as (a) above)
(e) Insert
(f) Display <-- shows 6 rows, not 3
I have confirmed with File Explorer that the database file is deleted and
then recreated as part of the Create logic.
As a second test, I tried deleting the database between steps (e) and (f);
SQL CE was smart enough to throw an exception when I tried the "Display"
button. So it looks like SQL CE requires the DB file to exist, but its
contents are cached, and there's no date/time stamp checking to detect the
above condition.
Obviously there's some caching going on here. Exactly how does it work?
Richard Kucia
for me to come up with a puzzle. I created a little test app that gives the
user 3 buttons: Create, Insert and Display. "Create" deletes the SQL CE
database file (if it exists) and then creates a empty database with one
empty table named Books. "Insert" opens a connection to the DB, inserts 3
rows into the table "Books", and closes the connection. "Display" opens a
connection to the DB, populates a DataSet off a DataAdapter, sets a grid's
DataSource to the DataSet's "Books" table, and closes the connection. No
mystery here -- all ordinary stuff.
If I perform the following sequence, I see 6 rows in the grid, not 3.
(a) Create (creates an empty database with one table "Books" and zero rows)
(b) Insert (inserts 3 rows into "Books")
(c) Display (shows 3 rows)
(d) Create (same as (a) above)
(e) Insert
(f) Display <-- shows 6 rows, not 3
I have confirmed with File Explorer that the database file is deleted and
then recreated as part of the Create logic.
As a second test, I tried deleting the database between steps (e) and (f);
SQL CE was smart enough to throw an exception when I tried the "Display"
button. So it looks like SQL CE requires the DB file to exist, but its
contents are cached, and there's no date/time stamp checking to detect the
above condition.
Obviously there's some caching going on here. Exactly how does it work?
Richard Kucia