D
Dan
Hi all, I have a problem with the template code for an IDE-generated
dataform. You can easily reproduce it with the following steps:
1) create a dummy Access database with a table with a couple of fields:
ID = a numerical ID (e.g. autonumber)
somefield = a textual field which can be NULLABLE but NOT zero-length
(in Access terms, say "No" to required and "No" to allow zero length)
2) create a new windows form project with VS and let it create a data form
for this table.
3) launch the application and create a new record: do not enter anything for
the textual field, then update the data source. If you now open the table
with Access, you can see that the new record contains a NULL value for the
textual field, as expected (e.g. "SELECT * FROM DummyTable WHERE
IsNull(somefield)" shows it).
4) THIS IS THE POINT: now, edit again the same record: this time enter
something in the textual field, and update the database. Again, edit the
same record and CLEAR the textual field (delete all the characters in the
bound editbox). Then update the datasource: this will raise an Exception,
because the update command is trying to store NOT a NULL value but an EMPTY
string, and by this database design an empty string is not allowed there.
Now, is there a way to tell the update command that when a bound text
control is empty it should store a NULL and not an empty string?
Thanks in advance...
dataform. You can easily reproduce it with the following steps:
1) create a dummy Access database with a table with a couple of fields:
ID = a numerical ID (e.g. autonumber)
somefield = a textual field which can be NULLABLE but NOT zero-length
(in Access terms, say "No" to required and "No" to allow zero length)
2) create a new windows form project with VS and let it create a data form
for this table.
3) launch the application and create a new record: do not enter anything for
the textual field, then update the data source. If you now open the table
with Access, you can see that the new record contains a NULL value for the
textual field, as expected (e.g. "SELECT * FROM DummyTable WHERE
IsNull(somefield)" shows it).
4) THIS IS THE POINT: now, edit again the same record: this time enter
something in the textual field, and update the database. Again, edit the
same record and CLEAR the textual field (delete all the characters in the
bound editbox). Then update the datasource: this will raise an Exception,
because the update command is trying to store NOT a NULL value but an EMPTY
string, and by this database design an empty string is not allowed there.
Now, is there a way to tell the update command that when a bound text
control is empty it should store a NULL and not an empty string?
Thanks in advance...