'Declaration Public Overrides Property Direction As ParameterDirection
public override ParameterDirection Direction {get; set;}
'Declaration Public Overrides Property Direction As ParameterDirection
public override ParameterDirection Direction {get; set;}
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.
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
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