8. Working with Images and Text Strings : How You Can Work with Text Strings : How You Can Update Strings in a Database : How You Can Replace the Current StringObject Value
 
Share this page                  
How You Can Replace the Current StringObject Value
Replacing the string in the database with the current value of the StringObject object is useful when the user has entered a value into an entry field or changed the value in the entry field, and you want the update to be reflected in the database.
After the user completes the changes, use the UpdateInDB method to remove the old string from the database and add the new string (the current value of the StringObject object) in its place.
To make this change, you would perform the following basic steps:
1. Set the value of the DBHandle attribute to the DBHandle for the string you want to replace.
2. Allow updates by the user.
3. Use the UpdateInDB method to remove the old string from the database and add the new string (the current value of the StringObject) in its place.
4. Commit the changes to the database.
The UpdateInDB method returns ER_OK if successful or a nonzero value if there is an error.
The new string has the same DBHandle as the old one. For more information about error handling for the UpdateInDB method, see Working with a Database (see Working with a Database).