Programming Guide : Working with Images and Text Strings : How You Can Work with Text Strings : How You Can Update Strings in a Database
 
Share this page          
How You Can Update Strings in a Database
There are two ways to update a string in the database:
Replace the string in the database with the current value of the StringObject object.
Replace the old string in the database with the contents of an external file.
The following sections describe each of these ways of updating strings.
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 Images and Text Strings.
How You Can Replace the Contents of an External File
You can replace an old string in the database with the contents of an external file. To replace an old string with the contents of an external file, 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. Set the FileHandle attribute to the file name that contains the new string. OpenROAD copies the new string into the StringObject object.
3. 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.
4. Commit the changes to the database.