8. Working with Images and Text Strings : How You Can Work with Text Strings : How You Can Store Strings in the Database : How You Can Load a String into the Database
 
Share this page                  
How You Can Load a String into the Database
Use the InsertIntoDB method to add a string to the table you specify or, if you do not specify a table, to the system table.
Note:  To use a string storage table other than the system table, you must set it up as described in How You Can Create a String Storage Table (see How You Can Create a String Storage Table).
To load a string into the database, you would perform the following basic steps:
1. Define a varchar(76) column to hold the DBHandles in the table that contains the data for the application.
2. Decide whether to store the strings in the system table or your own table.
3. If the text string is in a text file, set the FileHandle attribute of the StringObject to the file name. (If the user has entered the text into an entry field, the string is already stored in the StringObject object and it is not necessary to set the FileHandle attribute.)
For this step, if there is an entry field on your form, you can use the StringObject object associated with the entry field. If there is no entry field, declare a variable of type StringObject to use for loading the text.
4. Use the InsertIntoDB method to insert the string in the StringObject object into the database table.
After this method completes, OpenROAD stores the new DBHandle for the string in the DBHandle attribute.
5. Add the current value of the DBHandle attribute to your database table so that you can access the string the next time you need it.
6. Commit the changes to the database.
For more information about error handling for the InsertIntoDB method, see Working with a Database (see Working with a Database).
The string is now stored in the database. You can display the string time by setting the DBHandle attribute, and you can replace or delete the string if necessary with the UpdateInDB and DeleteFromDB methods respectively. These methods are described in How You Can Display a String from a Database (see How You Can Display a String from a Database) and How You Can Update Strings in a Database (see How You Can Update Strings in a Database).