DB2 10.5 for Linux, UNIX, and Windows

DB2String Structure

Represents the CHAR, VARCHAR, LONG VARCHAR, GRAPHIC, VARGRAPHIC and LONG VARGRAPHIC DB2® data types. Encapsulates the string .NET data type.

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

Syntax

[Visual Basic]
Public Structure DB2String
[C#]
public struct DB2String
[C++]
public value class DB2String

Example

[C#] The following example demonstrates how to retrieve character string column values from a table.

[C#]
  public static string getParam(DB2Connection conn)
  {
    string mySelectQuery = "SELECT * FROM EMPLOYEE WHERE WORKDEPT=(?)";
    DB2Command myCommand = new DB2Command(mySelectQuery, conn);
    DB2Parameter p1 = new DB2Parameter();
    DB2String dept = new DB2String("D11");
    p1.Value = dept;
    myCommand.Parameters.Add(p1);
    DB2DataReader reader = myCommand.ExecuteReader();

    if (reader.Read())
    {
      DB2String selectValue = reader.GetDB2String(3);

      if (!selectValue.IsNull) { return selectValue.ToString(); }
    }

    return "NULL";
  }

Thread safety

Any public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Any instance members are not guaranteed to be thread safe.