Direction Property (PgSqlParameter)
Gets or sets a value indicating whether the parameter is input-only, output-only, or bidirectional parameter.
Property Value
One of the
System.Data.ParameterDirection values. The default value is Input.
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