Click here to Skip to main content
15,895,829 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

My application should needs to function with minimum of changes if the database platform ever changes from Oracle to SQL Server.

which DataReader objects should I use to minimize the impact of a change to the database platform in the future?

A) IDataReader
B) OleDbDataReader

Thanks in advance.
Posted

Write a function which finds out which database your customer is using, then instantiate the specific type for it (i.e. OracleDataReader and SqlDataReader, resp.). They do inherit from IDataReader, hence in all the further code you need not differentiate.
Although it is true that you can connect to both SQL Server and Oracle via OleDb, I do recommend not to do so. OleDb is too unspecific when it comes to dealing correctly with some odd data types like datetime - especially localized - or guid etc.
Some functions need to be totally changed, e.g. bit operations, or getting the last insert id.
 
Share this answer
 
Comments
abhishekrvce 30-May-10 6:16am    
Thanks bhiller, i will go with IDataReader as it can use with Dynamic behavior of data base change.
In my experience it's always best to use the data objects provided by the framework for the specific database type, e.g. SQL Server objects for SQL server access.

I don't know if any such objects are supplied for Oracle, though.


But (this might be selfevident, but just in case you don't know it) you should restrict all your database access to your data layer and keep the code separate from the rest of the code. That way, when (if) it comes to changing the DB type, you (more or less) only need to change the "using" statement... (and perhaps make minor tweaks).

If your db code is spread all over the place, then this will become a major task...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900