且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从Oracle迁移到MS SQL Server

更新时间:2022-10-14 23:01:07

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.


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...