dotConnect for PostgreSQL Documentation
Devart.Data.PostgreSql Namespace / PgSqlRow Class / Parse(PgSqlRowType,String) Method
PgSqlRowType that describes data on value
String to parse.
Example

In This Topic
Parse(PgSqlRowType,String) Method
In This Topic
Parses provided string as data for composite type.
Syntax
'Declaration
 
Public Shared Function Parse( _
   ByVal rowType As PgSqlRowType, _
   ByVal value As String _
) As PgSqlRow
 

Parameters

rowType
PgSqlRowType that describes data on value
value
String to parse.

Return Value

Parsed string as PgSqlRow
Example
This sample shows how to obtain PgSqlRowType from server and create a PgSqlRow object on the client side. The object is later inserted into table.
static void InsertDataWithParameters(PgSqlConnection conn)
{
  string str = "INSERT INTO personnel VALUES (:ID, :ROW)";
  PgSqlCommand pgCommand = new PgSqlCommand(str,conn);
  //Create instance of PgSqlRow and parse data
  //Note that connection must be open
  PgSqlRowType pgRowType = PgSqlRowType.GetRowType("tperson", conn);
  PgSqlRow pgRow = PgSqlRow.Parse(pgRowType,"(''Robert'',30)");
  //provide parameters to command and execute it
  pgCommand.Parameters.Add("ID",4);
  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
  'Note that connection must be open
  Dim pgRowType As PgSqlRowType = PgSqlRowType.GetRowType("tperson", conn)
  Dim pgRow As PgSqlRow = PgSqlRow.Parse(pgRowType, "(''Robert'',30)")
  '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
See Also