Wednesday, February 6, 2008

Running into record changed by another user

Have you run into the problem using SQL Server and your front end gets an error saying the record you are trying to save has been changed by another user? I have run into this many times and you will not think what is actually causing the problem...



If you have created a table in SQL Server and you have a field defined as type BIT you must define a default value for this field. If you do not and do not set it in code when you add a record to the table (essentially leaving the field null), you will get an error like the one mentioned above.



I do not like using BIT types and create my tables using INTs. INTs can have a null value.



So use INT and do set your values either by default or in code. A NULL can cause other problems with reports and queries if you do not think to test for it.