If you're writing Integration Services code that uses the Execute SQL task, you also have to create parameters programmatically. The ParameterBindings property of the ExecuteSQLTask returns an IDTSParameterBindings collection of IDTSParameterBinding objects, each of which has a DataType property. But the DataType is just an integer. Where do the values come from? Why doesn't it just get its values from an enumeration that's clearly documented?
Well, the values for the DataType of an IDTSParameterBinding depend on the type of connection manager used in the Execute SQL task, as follows:
- For an ADO.NET or SQLMOBILE connection, the data types are from the System.Data.DbType enumeration.
- For an OLE DB or EXCEL connection, the data types are OLE DB data types. Also consult the oledb.h header file in the Windows SDK.
- For an ADO connection, the data types are from the ADODB.DataTypeEnum enumeration.
- For an ODBC connection, the data types are ODBC data types. Also consult the odbcss.h header file in the Windows SDK.
I've provided links above to the API reference pages in the MSDN Library. Unfortunately, the reference topics for enumerations don't include the integer values that you need.* At least you'll know which assembly and which type to open in Object Browser to find their numeric values.
*<rant>This has always infuriated me about the API documentation, because you need those integer values more often than you think. And it would be effortless for the reflection process that's already being run to crank them out automatically!.</rant>
Please comment on my blog!
You don't have to sign up or sign in - anonymous comments are enabled. I "moderate" the comments to delete spam before you see it, but otherwise, I publish your comments immediately. You can also email me at firstname.lastname@example.org. Thank you!