DB2Xml.GetString Method

Returns a UTF-16 string representing the contents of the DB2Xml object instance.

Namespace:
IBM.Data.DB2Types
Assembly:
IBM.Data.DB2 (in IBM.Data.DB2.dll)

Syntax


[Visual Basic]
Public Function GetString() As String
[C#]
public string GetString();
[C++]
public: String* GetString();
[JScript]
public function GetString() : String;

Return value

The value of the specified column as a character string.

Example

[C#]

The function in this example prints the contents of an XML column, named DESCRIPTION, from a table called PRODUCT. To retrieve the XML column data, use the DB2®DataReader.GetDB2Xml method, and pass the XML data to a DB2Xml object.

[C#] 
public static void ReadXmlColumn(DB2Connection conn)
{
   DB2Xml xmlColValue; 
   String xmlString;
   String cmdSQL = "SELECT DESCRIPTION FROM product WHERE pid='100-101-01'";
   DB2Command cmd = new DB2Command(cmdSQL, conn);
   DB2DataReader reader = cmd.ExecuteReader();
   try
   {
      while (reader.Read())
      {
         xmlColValue = reader.GetDB2Xml(0);
         xmlString = xmlColValue.GetString();
         Console.WriteLine(" {0} \n", xmlString);
      }
   }
   catch(Exception e)
   {
      Console.WriteLine(e.Message);
   }
   finally
   {
      reader.Close();
   }
}