What is the difference between SqlDataReader SqlTypes and DbType typed accessors?

123 views Asked by At

What is the difference between SqlDataReader SqlTypes and DbType typed accessors?

When is it more appropriate to use either?

1

There are 1 answers

0
Damien_The_Unbeliever On BEST ANSWER

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 as DbDataReader and then only the GetDecimal 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.