5. Working with a Database : Handling Database Errors : Choosing an Error Handling Strategy : How You Can Detect Errors When Working with Bitmaps, String, Long VChar, and Long Byte Objects
 
Share this page                  
How You Can Detect Errors When Working with Bitmaps, String, Long VChar, and Long Byte Objects
How you handle errors when you manipulate bitmaps, long byte, long varchar, or string objects depends on how you have stored these objects and what operations you are performing.
For example, if your bitmaps, long byte, long varchar, or string objects are stored in a file, whenever you use the WriteToFile method you can check the method's return value to detect errors. The WriteToFile method returns 0 if it was successful or a 1 if not.
If your bitmaps and string objects are stored in the database, use the InsertIntoDB, UpdateInDB, and DeleteFromDB methods to manipulate these objects in the database. If your long byte and long varchar objects are stored in the database, use the FetchFromDB or UpdateInDB methods to manipulate these objects in the database. When you do, your error checking should check not only the return status of the method but also the value of DBSessionObject's ErrorNumber attribute because these methods access the database, and it is possible for a DBMS error to occur.
Finally, you can set a FileHandle or DBHandle directly, for example, by an assignment statement. When you do so, you can check the ErrorStatus attribute for errors. For more information about this attribute, see How You Can Use the ErrorStatus Attribute (see How You Can Use the ErrorStatus Attribute).