diction

程序人生
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

c#中ExecuteReader ExecuteNonQuery ExecuteScalar ExecuteXmlReader的区别

Posted on 2007-10-12 08:33  黑*马  阅读(873)  评论(0)    收藏  举报

ExecuteReader     
 执行返回行的命令。为了提高性能,ExecuteReader    使用    Transact-SQL    sp_executesql    系统存储过程调用命令。
 因此,如果用于执行像    Transact-SQL    SET    语句这样的命令,ExecuteReader    可能无法获得预期效果;

ExecuteNonQuery    
 执行    Transact-SQL    INSERT、DELELE、UPDATE    及    SET    语句等命令,
 返回受影响行数,而在执行查询时则是返回一个0。

ExecuteScalar   
 执行查询,并返回查询所返回的结果集中第一行的第一列。
 忽略额外的列或行;

ExecuteXmlReader     
 将    CommandText    发送到    Connection    并生成一个    XmlReader    对象。