什么时候应该使用Odbc,OleDb,SQLClient?权衡是什么 [英] When should I be using Odbc, OleDb, SQLClient? What are the trade-offs
问题描述
我从一个SQLServer数据库开始.因此,似乎我应该使用 System.Data.SqlClient
命名空间.但是,有可能我们可能会关闭SqlServer数据库并转到MySql或Oracle.因此,我提出了一套有关.Net应用程序如何与数据库通信的标准,以便将来在需要时可以更轻松地迁移到其他数据库系统.>
所以这是标准:
- 请尽可能使用ORM(例如NHibernate)(没有LINQ,因为只有它支持SqlServer,但是怎么样实体框架及其支持Oracle和MySql?)
- 如果ORM过于强大,则使用参数化的SQL查询.
- 仅将存储过程用于长时间运行或复杂的操作,这些操作会需要在数据库.
哪个使我想到了我即将遇到的主要问题. 我应该使用哪个命名空间来编码我的DAL?
在我看来,选择是在 System.Data.ODBC
和 System.Data.OleDB
之间:
- 需要权衡些什么?
- 一个人优先于另一个人吗?
- 您对前三个标准有何看法?
System.Data.SQLClient
仅连接到SQL Server 2000和更高版本,但连接到这些数据库时将获得最佳性能.
System.Data.OledbClient
连接到SQL 6.5
OLEDBClient使您能够连接到其他数据库,例如ORACLE或Access.但是,使用SQL Server可以使用SQLClient获得更好的性能.
注意:为了连接到ORACLE,Microsoft还具有ORACLEClient.
System.Data.ODBCClient
使用ODBC驱动程序仅连接到旧数据库.(例如MS Access 97.)
System.Data.SQLClient
Connects to SQL Server 2000 and later only, but you will get optimal performance when connecting to those databases.
System.Data.OledbClient
Connects to SQL 6.5
OLEDBClient gives you ability to connect to other database like ORACLE or Access. But for working with SQL Server you will get better performance using SQLClient.
Note: For connecting to ORACLE, Microsoft also has ORACLEClient.
System.Data.ODBCClient
Connects to legacy databases only, using ODBC drivers. (E.g. MS Access 97.)
这篇关于什么时候应该使用Odbc,OleDb,SQLClient?权衡是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!