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

  • 相关阅读:
    angularjs
    HTML5
    Java Concurrency —— 《Java并发编程实战》读书笔记
    java IO
    Struts2 文件上传下载
    SQL join
    Annotation
    if表达式
    Ext js 下拉框下拉的同时输入模糊查询
    JSP如何把一个页面的值传到另一个页面
  • 原文地址:https://www.cnblogs.com/lthxk-yl/p/3368483.html
Copyright © 2011-2022 走看看