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

  • 相关阅读:
    字符串转换整数 (atoi)
    Z 字形变换
    最长回文子串
    寻找两个有序数组的中位数
    二维码QRCode
    多个线程访问url
    store procedure 翻页
    store procedure example
    使用graphics2D给图片上画字符
    procedure的over(partition by ) function
  • 原文地址:https://www.cnblogs.com/lthxk-yl/p/3368483.html
Copyright © 2011-2022 走看看