开发者

Data Adapter vs SQLCommand

I am confused about the SQL Data Adapter in ADO.Net.

What is the difference between the below:

SqlDataAdapter adapter = new SqlDataAdapter("Select * from Course", sqlconn);

and

 SqlCommand Command = new SqlCommand("Select * from Course", sql开发者_Python百科conn);

Can someone please explain?


The basic answer is: Not a lot in the guts of it.

SQLDataAdapter uses SQLCommand

The main differences are:

  1. DataAdapter can populate directly into a DataTable, the command returns a DataReader
  2. DataAdapter can use multiple Commands to support Select, Insert, Update and Delete commands

So you would use Command to get a DataReader to iterate once over everything it returns.

You would use DataAdapter to put it all into a DataTable to reuse it, and to support pushing data back to the DB server.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜