'Declaration Public Shadows ReadOnly Property Parameters As PgSqlParameterCollection
public new PgSqlParameterCollection Parameters {get;}
'Declaration Public Shadows ReadOnly Property Parameters As PgSqlParameterCollection
public new PgSqlParameterCollection Parameters {get;}
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++) { pgCommand.Parameters.Add(myParamArray[i]); myMessage += pgCommand.Parameters[i].ToString() + "\n"; } Console.Write(myMessage); try { pgConnection.Open(); pgCommand.ExecuteNonQuery(); } finally { pgConnection.Close(); } } 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); }
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) pgCommand.Parameters.Add(myParamArray(i)) myMessage = String.Concat(myMessage, " ", pgCommand.Parameters(i).ToString()) Next Console.WriteLine(myMessage) Try pgConnection.Open() pgCommand.ExecuteNonQuery() Finally pgConnection.Close() 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
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