GetString

This method returns the string value of the specified column.

Declaration

// C#
public override string GetString(int index);

Parameters

  • index

    The zero-based column index.

Return Value

The string value of the column.

Implements

IDataRecord

Exceptions

InvalidOperationException - The connection is closed, the reader is closed, Read() has not been called, or all rows have been read.

IndexOutOfRangeException - The column index is invalid.

InvalidCastException - The accessor method is invalid for this column type or the column value is NULL.

Remarks

GetString() can be called on all character-based column data types. Starting with version 19.10, GetString() can be called on all non-binary data types, returning a string representation of the following additional types with the NLS format session setting honored:

  • NUMBER

  • DATE

  • TIMESTAMP

  • TIMESTAMP LTZ

  • TIMESTAMP TZ

  • INTERVAL YEAR TO MONTH

  • INTERVAL DAY TO SECOND

  • BINARY_DOUBLE

  • BINARY_FLOAT

  • FLOAT

Call the IsDBNull method to check for null values before calling this method.

If the column is an Oracle REF column, the string returned is a hexadecimal string that represents the REF in the database.