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

In This Topic
    Direction Property (PgSqlParameter)
    In This Topic
    Gets or sets a value indicating whether the parameter is input-only, output-only, or bidirectional parameter.
    Syntax
    'Declaration
     
    Public Overrides Property Direction As ParameterDirection
    public override ParameterDirection Direction {get; set;}

    Property Value

    One of the System.Data.ParameterDirection values. The default value is Input.
    Remarks

    Set Direction to System.Data.ParameterDirection.ReturnValue to obtain query result as parameter.

    If the System.Data.ParameterDirection is System.Data.ParameterDirection.Output or System.Data.ParameterDirection.InputOutput, an exception is thrown.

    Please refer to article Using Parameters for more information about parameters in dotConnect for PostgreSQL.

    Example
    This sample demonstrates how to retrieve the return value of a stored procedure with PgSqlParameter
    using System;
    using System.Data;
    using Devart.Data.PostgreSql;
    
    namespace ConsoleApplication4 {
      
      class Class1 {
    
        [STAThread]
        static void Main(string[] args) {
    
          PgSqlConnection connection = new PgSqlConnection("host=server;database=testdb;user=postgres;");
          PgSqlCommand command = connection.CreateCommand();
          PgSqlParameter pDeptNo, pDeptName, pDeptLoc;
    
          command.CommandText = "getdept";
          command.CommandType = CommandType.StoredProcedure;
    
          pDeptNo = command.Parameters.Add("deptno", PgSqlType.Int);
          pDeptName = command.Parameters.Add("deptname", PgSqlType.VarChar, 12);
          pDeptLoc = command.Parameters.Add("loc", PgSqlType.VarChar, 13);
    
          pDeptNo.Direction = ParameterDirection.ReturnValue;
          pDeptName.Direction = ParameterDirection.ReturnValue;
          pDeptLoc.Direction = ParameterDirection.ReturnValue;
    
          command.ExecuteNonQuery();
          connection.Close();
    
          Console.Write("deptno = {0}, deptname = {1}, loc = {2}", pDeptNo.Value, pDeptName.Value, pDeptLoc.Value);
          Console.ReadLine();
        }
      }
    }
    Imports Devart.Data.PostgreSql
    
    Module Module1
    
      Sub Main()
        Dim connection As PgSqlConnection = New PgSqlConnection("host=server;database=testdb;user=postgres;")
        Dim command As PgSqlCommand
        Dim pDeptNo, pDeptName, pDeptLoc As PgSqlParameter
    
        connection.Open()
        command = connection.CreateCommand()
        command.CommandText = "getdept"
        command.CommandType = CommandType.StoredProcedure
    
        pDeptNo = command.Parameters.Add("deptno", PgSqlType.Int)
        pDeptName = command.Parameters.Add("deptname", PgSqlType.VarChar, 12)
        pDeptLoc = command.Parameters.Add("loc", PgSqlType.VarChar, 13)
    
        pDeptNo.Direction = ParameterDirection.ReturnValue
        pDeptName.Direction = ParameterDirection.ReturnValue
        pDeptLoc.Direction = ParameterDirection.ReturnValue
    
        command.ExecuteNonQuery()
        connection.Close()
    
        Console.Write("deptno = {0}, deptname = {1}, loc = {2}", pDeptNo.Value, pDeptName.Value, pDeptLoc.Value)
        Console.ReadLine()
      End Sub
    End Module
    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