METHOD

DbCommand.CreateParameter

Creates a parameter using the command provider. Configure name, type and value, then add it to the parameter collection. Creating a parameter does not attach it to the command or make SQL identifiers bindable. Requires the reviewed Microsoft.Data.Sqlite package.

Formal Syntax & Structure

csharp syntaxcsharp
var p = command.CreateParameter();

Working Example

Example Snippetcsharp
using System;using System.Data;using System.Data.Common;using Microsoft.Data.Sqlite;using var c=new SqliteConnection("Data Source=:memory:;Pooling=False"); using var cmd=c.CreateCommand(); var p=cmd.CreateParameter(); p.ParameterName="$id"; p.DbType=DbType.Int64; p.Value=7L; cmd.Parameters.Add(p); Console.WriteLine(cmd.Parameters.Count); // 1
C# & .NET Reference