dotConnect for SQLite Documentation
Devart.Data.SQLite Namespace / SQLiteCommand Class / Parameters Property
Example

Parameters Property
Gets or sets the SQLiteParameterCollection.
Syntax
'Declaration
 
Public Shadows ReadOnly Property Parameters As SQLiteParameterCollection
 

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 SQLiteConnection, SQLiteCommand, fills its parameters and displays them. An UPDATE statement with the parameters involved is executed then.
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);
}
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

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

See Also