What is the difference between SqlDataReader SqlTypes and DbType typed accessors?
When is it more appropriate to use either?
What is the difference between SqlDataReader SqlTypes and DbType typed accessors?
When is it more appropriate to use either?
If your code needs to be provider agnostic and work against multiple database systems, you should avoid using SQL Server specific functionality, your code should not reference
SqlDataReader
at all. It should use the neutral types such asDbDataReader
and then only theGetDecimal
method are available.On the other hand, if you're happy to tie your implementation to SQL Server specifically, or you're already having to be implementation specific, then I'd suggest using the SQL Server specific accessors (e.g.
GetSqlDecimal
) and types, since they are more specifically aligned with the SQL Server data types.