dotConnect for SQLite Documentation
Parameters Property
See Also  Example Send comments on this topic.
Devart.Data.SQLite Namespace > SQLiteCommand Class : Parameters Property

Gets or sets the SQLiteParameterCollection.

Syntax

Visual Basic (Declaration) 
Public Shadows ReadOnly Property Parameters As SQLiteParameterCollection
C# 
public new SQLiteParameterCollection Parameters {get;}

Property Value

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

Remarks

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

Example

The following example creates a Devart.Data.SQLite.SQLiteConnection, SQLiteCommand, fills its parameters and displays them. An UPDATE statement with the parameters involved is executed then.
C#csharpCopy Code
static void CreateCommand(SQLiteConnection sqConnection, string mySelectQuery, SQLiteParameter[] myParamArray)
{
  SQLiteCommand sqCommand = new SQLiteCommand(mySelectQuery, sqConnection);
  string myMessage = "";
  for (int i = 0; i < myParamArray.Length; i++)
  {
    sqCommand.Parameters.Add(myParamArray[i]);
    myMessage += sqCommand.Parameters[i].ToString() + "\n";
  }
  Console.Write(myMessage);
  try
  {
    sqConnection.Open();
    sqCommand.ExecuteNonQuery();
  }
  finally
  {
    sqConnection.Close();
  }
}

static void Main(string[] args)
{
  SQLiteParameter[] myParams = new SQLiteParameter[] 
    {
      new SQLiteParameter("DeptNo", 10),
      new SQLiteParameter("DName", "COUNTING")
    };
  SQLiteConnection sqConnection1 = new SQLiteConnection(
      "DataSource=mydatabase.db;");
  CreateCommand(sqConnection1,"UPDATE Dept SET DName = :DName WHERE DeptNo = :DeptNo",myParams);
}
C#Visual BasicCopy Code
Public Sub CreateCommand(ByVal sqConnection As Devart.Data.SQLite.SQLiteConnection, _
 ByVal mySelectQuery As String, ByVal myParamArray() As Devart.Data.SQLite.SQLiteParameter)
  Dim sqCommand As New Devart.Data.SQLite.SQLiteCommand(mySelectQuery, sqConnection)
  Dim myMessage As String = ""
  Dim i As Integer
  For i = 0 To (myParamArray.Length - 1)
    sqCommand.Parameters.Add(myParamArray(i))
    myMessage = String.Concat(myMessage, " ", sqCommand.Parameters(i).ToString())
  Next
  Console.WriteLine(myMessage)
  Try
    sqConnection.Open()
    sqCommand.ExecuteNonQuery()
  Finally
    sqConnection.Close()
  End Try
End Sub

Sub Main()
  Dim myP1 As New Devart.Data.SQLite.SQLiteParameter
  myP1.ParameterName = "DeptNo"
  myP1.Value = 10
  Dim myP2 As New Devart.Data.SQLite.SQLiteParameter
  myP2.ParameterName = "DName"
  myP2.Value = "ACCOUNTING"
  Dim myParams(1) As Devart.Data.SQLite.SQLiteParameter
  myParams(0) = myP1
  myParams(1) = myP2
  Dim sqConnection1 As New Devart.Data.SQLite.SQLiteConnection( _
      "DataSource=mydatabase.db;")
  CreateCommand(sqConnection1, "UPDATE Dept SET DName = :DName WHERE DeptNo = :DeptNo", myParams)
End Sub

Requirements

Platforms:Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family, Windows 7, Windows 8, Windows 10, Windows Server 2012 family.

See Also