zoukankan      html  css  js  c++  java
  • SqlCommand 的 4个方法

    1 :  ExecuteNonQuery()
    Executes non-SELECT commands, such as SQL commands that insert,delete, or update records. The returned value indicates the number of rows affected by the command. You can also use ExecuteNonQuery() to
    execute data-definition commands that create, alter, or delete database objects (such as tables, indexes, constraints, and so on).

    返回值表明多少行受影响

    2 : ExecuteScalar()
    Executes a SELECT query and returns the value of the first field of the first
    row from the rowset generated by the command. This method is usually used when executing an aggregate SELECT command that uses functions such as COUNT() or SUM() to calculate a single value.

    只返回第一行第一列

    3 : ExecuteReader()
    Executes a SELECT query and returns a DataReader object that wraps a
    read-only, forward-only cursor.

    执行select语句  返回SqlDataReader

    4 : ExecuteXmlReader()
    Sends the CommandText to the Connection and builds an XmlReader object.

    返回XmlReader , 查询xml 字段时用

    -------------------------------------------------

    1,2,3 Net Framwork 3.5 可用     4 需要 Net Framework 4.0

  • 相关阅读:
    easyui tree loader用法
    mysql字符集
    mysql 内连接 左连接 右连接 外连接
    mysql 聚集函数和分组
    mysql 大数据量求平均值
    C++ 纯虚方法
    Windows xcopy
    服务端数据库的操作如何不阻塞
    分布式系统业务服务器的设计
    mysql 查询执行的流程
  • 原文地址:https://www.cnblogs.com/lthxk-yl/p/3368483.html
Copyright © 2011-2022 走看看