I had tried to use "ADO NET Destination" [VS2017 + SSDT] with my ADO.NET Provider and found the problem.
// C:\WINDOWS\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.ADONETDest\v4.0_14.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.ADONETDest.dll
// Microsoft.SqlServer.ADONETDest, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91
// Global type: <Module>
// Architecture: AnyCPU (64-bit preferred)
// Runtime: v4.0.30319
See this code of ADONETDestination::PreExecute:
stringBuilder.Append(") VALUES ("); string parmameterMarkerFormat = getParmameterMarkerFormat(); PostDiagnosticMessage(Microsoft.SqlServer.Dts.Pipeline.Localized.DiagnosticPre("DbProviderFactory.CreateParameter")); string empty = string.Empty; for (int k = 0; k <= num; k++) { empty = string.Format(CultureInfo.InvariantCulture, "{0}{1:d}", new object[2] { "p", k + 1 }); empty = string.Format(CultureInfo.InvariantCulture, parmameterMarkerFormat, new object[1] { empty }); DbParameter dbParameter = m_DbFactory.CreateParameter(); dbParameter.ParameterName = empty;
Source code of getParmameterMarkerFormat:
private string getParmameterMarkerFormat() { if (m_DbConnection.GetType().Equals(typeof(SqlConnection))) { return "@{0}"; } DataTable schema = m_DbConnection.GetSchema(DbMetaDataCollectionNames.DataSourceInformation); return (string)schema.Rows[0]["ParameterMarkerFormat"]; }
Short description of problem
You use parameter name for generate parameter marker name and replaceparameter name by this parameter marker name.
---
See documentation about "ParameterMarkerFormat" column:
ParameterMarkerFormat string
A format string that represents how to format a parameter.If named parameters are supported by the data source, the first placeholder in this string should be where the parameter name should be formatted.
(1) For example, if the data source expects parameters to be named and prefixed with an ‘:’ this would be ":{0}". When formatting this with a parameter name of "p1" the resulting string is ":p1".
(2) If the data source expects parameters to be prefixed with the ‘@’, but the names already include them, this would be ‘{0}’, and the result of formatting a parameter named "@p1" would simply be "@p1".
First (1) case
When my provider configured for "parameter name NOT includes prefix", it return ":{0}".
PreExecute generates SQL "INSERT INTO ... VALUES(:p1)" and creates parameter with name ":p1".
As result, my provider generates error "parameter with unknown name [:p1]".
Second (2) case
When my provider configured for "parameter name already has (includes) prefix", it returns "{0}".
PreExecute generates SQL "INSERT INTO ... VALUES(p1)" and creates parameter with name "p1"
As result, DBMS generates error at prepare stage - "unknown column [p1]".
----
Dmitry Kovalenko
www.ibprovider.com
https://www.nuget.org/packages/lcpi.data.oledb/