Difference between revisions of "DatabaseColumn.StringValue"

From Xojo Documentation

(Created page with "N/A")
 
 
Line 1: Line 1:
N/A
+
{{PropertyBox
 +
| name=StringValue
 +
| owner=[[DatabaseColumn]]
 +
| ownertype=class
 +
| scope=public
 +
| type=[[String]]
 +
| platform=all
 +
| newinversion=2019r2
 +
}}
 +
{{Description
 +
|text = Used to get and set the values of [[String]]/Character field types. }}
 +
 
 +
==Notes==
 +
If the field is not of this type, '''StringValue''' will try to return the value as a [[String]]. [[SQLiteDatabase]] converts text to UTF-8 text encoding.
 +
 
 +
When using this property to assign binary data, no encoding is added.
 +
 
 +
For situations where you need to set a database column to NULL, you should use the Value property like this:
 +
<rbcode>
 +
rs.EditRow
 +
rs.Column("MyStringColumn").Value = Nil // sets to NULL in the database
 +
rs.SaveRow
 +
</rbcode>
 +
 
 +
== Sample Code ==
 +
Get the string value of a column in a [[RowSet]]:
 +
<rbcode>
 +
// rs is a RowSet with a string column called "ProductName"
 +
Var productName As String
 +
productName = rs.Column("ProductName").StringValue
 +
</rbcode>
 +
 
 +
Set the string value of a column in a [[RowSet]]:
 +
<rbcode>
 +
// rs is a Rowset with a string column called "ProductName":
 +
rs.EditRow
 +
rs.Column("ProductName").StringValue = "Generic Widgets"
 +
rs.SaveRow
 +
</rbcode>

Latest revision as of 20:33, 10 July 2019

Property (As String )
aDatabaseColumn.StringValue = newStringValue
or
StringValue = aDatabaseColumn.StringValue

New in 2019r2

Supported for all project types and targets.

Used to get and set the values of String/Character field types.

Notes

If the field is not of this type, StringValue will try to return the value as a String. SQLiteDatabase converts text to UTF-8 text encoding.

When using this property to assign binary data, no encoding is added.

For situations where you need to set a database column to NULL, you should use the Value property like this:

rs.EditRow
rs.Column("MyStringColumn").Value = Nil // sets to NULL in the database
rs.SaveRow

Sample Code

Get the string value of a column in a RowSet:

// rs is a RowSet with a string column called "ProductName"
Var productName As String
productName = rs.Column("ProductName").StringValue

Set the string value of a column in a RowSet:

// rs is a Rowset with a string column called "ProductName":
rs.EditRow
rs.Column("ProductName").StringValue = "Generic Widgets"
rs.SaveRow