See Also

SQLiteCommand Class  | SQLiteCommand Members  | SQLiteParameter Class  | CommandText Property

Language

Visual Basic

C#

Show All

See AlsoLanguagesDevart.Data.SQLiteSend comments on this topic.

Parameters Property

Devart.Data.SQLite Namespace > SQLiteCommand Class : Parameters Property

Gets or sets the SQLiteParameterCollection.

[Visual Basic]
Public ReadOnly Property Parameters As SQLiteParameterCollection
[C#]
public SQLiteParameterCollection Parameters {get;}

Return Type

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 Devart.Common.DbCommandBase.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.

[C#] 

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); 

[Visual Basic] 

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

See Also

SQLiteCommand Class  | SQLiteCommand Members  | SQLiteParameter Class  | CommandText Property

 

 


© 2008 - 2014 Devart. All Rights Reserved.