dotConnect for PostgreSQL Documentation
Devart.Data.PostgreSql Namespace / PgSqlParameter Class / RowType Property
Example

In This Topic
    RowType Property (PgSqlParameter)
    In This Topic
    Sets type of parameter in case of PostgreSQL composite value passed as string.
    Syntax
    'Declaration
     
    Public Property RowType As PgSqlRowType
    public PgSqlRowType RowType {get; set;}

    Property Value

    Composite type of Devart.Common.DbParameterBase.Value.
    Remarks

    The RowType and RowTypeName properties are linked. Therefore, setting the RowType changes the RowTypeName to value of PgSqlRowType.Name property. When you set RowTypeName property, RowType becomes a null reference (Nothing in Visual Basic).

    The RowType property can be used when you provide data as string and want to have it parsed as certain composite type. The other way to pass a PgSqlRow as parameter value is to assign a PgSqlRow object directly to Devart.Common.DbParameterBase.Value property.

    Example

    The following example demonstrates how to construct a PgSqlRow object and use it as parameter value.

    CREATE TYPE tperson AS (name text, age integer)

    CREATE TABLE personnel (id integer, person tperson)

    static void InsertDataWithParameters(PgSqlConnection conn)
    {
      string str = "INSERT INTO personnel VALUES (:ID, :ROW)";
      PgSqlCommand pgCommand = new PgSqlCommand(str,conn);
      //Create instance of PgSqlRow and fill with data
      PgSqlRow pgRow = new PgSqlRow("tperson",conn);
      pgRow[0] = "Fred";
      pgRow[1] = 24;
      //provide parameters to command and execute it
      pgCommand.Parameters.Add("ID",3);
      pgCommand.Parameters.Add("ROW",pgRow);
      pgCommand.ExecuteNonQuery();
      Console.WriteLine("Record added");
    }
    Sub InsertDataWithParameters(ByVal conn As PgSqlConnection)
      Dim str As String = "INSERT INTO personnel VALUES (:ID, :ROW)"
      Dim pgCommand As PgSqlCommand = New PgSqlCommand(str, conn)
      'Create instance of PgSqlRow and fill with data
      Dim pgRow As PgSqlRow = New PgSqlRow("tperson", conn)
      pgRow(0) = "Fred"
      pgRow(1) = 24
      'provide parameters to command and execute it
      pgCommand.Parameters.Add("ID", 3)
      pgCommand.Parameters.Add("ROW", pgRow)
      pgCommand.ExecuteNonQuery()
      Console.WriteLine("Record added")
    End Sub
    Requirements

    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also