tursodatabase/turso · error · ArgumentException
Parameter {value} is not a TursoParameter
Error message
Parameter {value} is not a TursoParameter What it means
TursoParameterCollection.SetParameter(int index, DbParameter value) backs the integer indexer setter and throws this ArgumentException when the value is not a TursoParameter ('value as TursoParameter' yields null). The collection is strongly typed by design; it never wraps or converts foreign DbParameter types.
Source
Thrown at bindings/dotnet/src/Turso.Data/TursoParameterCollection.cs:114
_parameters.RemoveAt(index);
}
protected override DbParameter GetParameter(int index)
{
return _parameters[index];
}
protected override DbParameter GetParameter(string parameterName)
{
return _parameters.Find(p => p.ParameterName == parameterName)
?? throw new ArgumentException($"Parameter {parameterName} not found");
}
protected override void SetParameter(int index, DbParameter value)
{
_parameters[index] = value as TursoParameter
?? throw new ArgumentException($"Parameter {value} is not a TursoParameter");
}
protected override void SetParameter(string parameterName, DbParameter value)
{
var index = IndexOf(parameterName);
if (index == -1)
throw new ArgumentException($"Parameter {parameterName} not found");
_parameters[index] = value as TursoParameter
?? throw new ArgumentException($"Parameter {value} is not a TursoParameter");
}
}
View on GitHub (pinned to 244cde92a7)
Solutions
- Create the replacement with new TursoParameter(...) before assigning it to the indexer.
- In provider-agnostic code, build parameters via cmd.CreateParameter() so the type always matches the collection.
- Copy Name/Value/DbType from the foreign parameter into a fresh TursoParameter instead of assigning it directly.
Example fix
// before
cmd.Parameters[0] = new SqlParameter("@id", 42);
// after
cmd.Parameters[0] = new TursoParameter("@id", 42); Defensive patterns
Strategy: type-guard
Type guard
static bool IsTursoParam(DbParameter p) => p is TursoParameter;
Prevention
- In provider-agnostic code create parameters with cmd.CreateParameter().
- Copy name/value into a new TursoParameter instead of assigning foreign DbParameter objects.
When it happens
Trigger: Assigning cmd.Parameters[0] = new SqlParameter(...) / new SqliteParameter(...) / any custom DbParameter subclass; passing a DbParameter-typed variable that actually holds another provider's type; generic factory code parameterized on DbProviderFactory reusing parameter objects across providers.
Common situations: Multi-provider code that creates parameters with one factory and assigns them to another provider's command; refactoring from SqlClient where collections sometimes accepted conversions; helper libraries storing parameters as DbParameter.
Related errors
- Parameter {value} not found
- Parameter {parameterName} not found
- Parameter must be of type TursoParameter
- Only input parameters are supported
- Connection must be a SqliteConnection.
AI-assisted analysis of tursodatabase/turso@244cde92a7 (2026-08-20).
Data as JSON: /api/errors/062c55a744c883ec.
Report an issue: GitHub.