SqlDataReader vs SqlDataAdapter: which one has the better performance for returning a DataTable?

后端 未结 5 1840
陌清茗
陌清茗 2020-12-24 03:12

I want to know which one has the better performance for returning a DataTable. Here for SqlDataReader I use DataTable.Load(dr)

5条回答
  •  失恋的感觉
    2020-12-24 03:54

    In addition to the selected solution, I would like to add that:

    Using the DataReader, you don´t need to know which type of DbConnection you have.

    All you need is an instance which implements IDbConnection, with that you can use "connection.CreateCommand" and then "dbCommand.ExecuteReader" and then dataTable.Load.

    But when you use DataAdapter you will need to know which connection is used (i.e. oracle, sqlserver, etc.)

    (It´s not relevant for the thread starter, but I landed here using g**gle while looking for this topic.)

提交回复
热议问题