See Also

PgSqlCommand Class  | PgSqlCommand Members  | PgSqlParameter Class  | CommandText Property


Visual Basic


Show All

See AlsoLanguagesDevart.Data.PostgreSqlSend comments on this topic.

Parameters Property

Devart.Data.PostgreSql Namespace > PgSqlCommand Class : Parameters Property

Gets or sets the PgSqlParameterCollection.

[Visual Basic]
Public ReadOnly Property Parameters As PgSqlParameterCollection
public PgSqlParameterCollection Parameters {get;}

Return Type

The parameters of a SQL statement or a stored procedure. The default value is an empty collection.


By default, you have to construct this collection and provide values for it manually. However, if you choose to use autosynchronization mode by setting Devart.Common.DbCommandBase.ParameterCheck property to true you can have the collecton adjusted automatically. Please refer to article Using Parameters in dotConnect for PostgreSQL for detailed information on using this mode.


The following example creates a PgSqlConnection, PgSqlCommand, fills its parameters and displays them. An UPDATE statement with the parameters involved is executed then.


static void CreateCommand(PgSqlConnection pgConnection, string mySelectQuery, PgSqlParameter[] myParamArray) 

  PgSqlCommand pgCommand = new PgSqlCommand(mySelectQuery, pgConnection); 
  string myMessage = ""; 
  for (int i = 0; i < myParamArray.Length; i++) 
    myMessage += pgCommand.Parameters[i].ToString() + "\n"; 

static void Main(string[] args) 

  PgSqlParameter[] myParams = new PgSqlParameter[]  
      new PgSqlParameter("DeptNo", 10), 
      new PgSqlParameter("DName", "COUNTING") 
  PgSqlConnection pgConnection1 = new PgSqlConnection( 
      "host=server;database=test;user id=postgres;"); 
  CreateCommand(pgConnection1,"UPDATE Test.Dept SET DName = :DName WHERE DeptNo = :DeptNo",myParams); 

[Visual Basic] 

Public Sub CreateCommand(ByVal pgConnection As Devart.Data.PostgreSql.PgSqlConnection, _
 ByVal mySelectQuery As String, ByVal myParamArray() As Devart.Data.PostgreSql.PgSqlParameter)
  Dim pgCommand As New Devart.Data.PostgreSql.PgSqlCommand(mySelectQuery, pgConnection)
  Dim myMessage As String = ""
  Dim i As Integer
  For i = 0 To (myParamArray.Length - 1)
    myMessage = String.Concat(myMessage, " ", pgCommand.Parameters(i).ToString())
  End Try
End Sub

Sub Main()
  Dim myP1 As New Devart.Data.PostgreSql.PgSqlParameter
  myP1.ParameterName = "DeptNo"
  myP1.Value = 10
  Dim myP2 As New Devart.Data.PostgreSql.PgSqlParameter
  myP2.ParameterName = "DName"
  myP2.Value = "ACCOUNTING"
  Dim myParams(1) As Devart.Data.PostgreSql.PgSqlParameter
  myParams(0) = myP1
  myParams(1) = myP2
  Dim pgConnection1 As New Devart.Data.PostgreSql.PgSqlConnection( _
      "host=server;database=test;user id=postgres;")
  CreateCommand(pgConnection1, "UPDATE Test.Dept SET DName = :DName WHERE DeptNo = :DeptNo", myParams)
End Sub

See Also

PgSqlCommand Class  | PgSqlCommand Members  | PgSqlParameter Class  | CommandText Property



© 2003 - 2016 Devart. All Rights Reserved.