dotConnect for SQLite Documentation
Devart.Data.SQLite Namespace / SQLiteCommand Class / CreateParameter Method
Example

In This Topic
    CreateParameter Method (SQLiteCommand)
    In This Topic
    Creates a new instance of a SQLiteParameter object.
    Creates a new instance of a SQLiteParameter object.
    Syntax
    'Declaration
     
    Public Shadows Function CreateParameter() As SQLiteParameter
    public new SQLiteParameter CreateParameter()

    Return Value

    A SQLiteParameter object.
    Remarks
    This method is a strongly-typed version of System.Data.IDbCommand.CreateParameter. See SQLiteParameter to find out more ways to create a parameter.
    Example
    This sample shows how to create a parameter using CreateParameter function.
    Public void CreateParam(SQLiteConnection sqConnection)
    {
      SQLiteCommand sqCommand = new SQLiteCommand("SELECT * FROM Dept WHERE DeptNo=:Deptno",sqConnection);
      SQLiteParameter myParam = sqCommand.CreateParameter();
      myParam.SQLiteType = Devart.Data.SQLite.SQLiteType.Int32;
      myParam.Value = 10;
      myParam.ParameterName = "Deptno";
      sqCommand.Parameters.Add(myParam);
      sqConnection.Open();
      SQLiteDataReader sqReader = null; 
      try
      {
        sqReader = sqCommand.ExecuteReader(); 
        while (sqReader.Read())
        {
          Console.WriteLine(sqReader.GetInt32(0) + ", " + sqReader.GetString(1) + ", " + sqReader.GetString(2));
        }
      }
      finally
      {
        sqReader.Close();
        sqConnection.Close();
      }
    }
    Public Sub CreateParam(ByVal sqConnection As SQLiteConnection)
      Dim sqCommand As New SQLiteCommand("SELECT * FROM Dept WHERE DeptNo=:Deptno", sqConnection)
      Dim myParam As SQLiteParameter = sqCommand.CreateParameter()
      myParam.SQLiteType = Devart.Data.SQLite.SQLiteType.Int32
      myParam.Value = 10
      myParam.ParameterName = "Deptno"
      sqCommand.Parameters.Add(myParam)
      sqConnection.Open()
      Dim sqReader As SQLiteDataReader = Nothing
      Try
        sqReader = sqCommand.ExecuteReader()
        While sqReader.Read()
          Console.WriteLine(sqReader.GetInt32(0).ToString() + ", " _
            + sqReader.GetString(1) + ", " _
            + sqReader.GetString(2))
        End While
      Finally
        sqReader.Close()
        sqConnection.Close()
      End Try
    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