VS. NET (C #) Database Interface: common attributes and methods of SqlCommand objects, vs.net

Source: Internet
Author: User

VS. NET (C #) Database Interface: common attributes and methods of SqlCommand objects, vs.net

Common attributes

Attribute

Description

CommandText

The return type is string. Obtain or set the SQL statement, stored procedure, or table to be executed on the data source.

CommandTimeOut

The return type is int, which gets or sets the waiting time before the Command Execution Attempt is terminated and an error is generated.

CommandType

The return type is CommandType. Reading or setting indicates how the CommandText attribute is interpreted. The valid value can be CommandType. text, CommandType. storedProcedur and CommandType. tableDirect, indicating SQL statements, stored procedure calls, or tables to be read. The default value is Text.

Connection

The return type is string. Obtain or set the SqlConnection used by this instance of SqlCommand.

Parameters

The return type is SqlParameterCollection. Obtain the parameters provided to the command and bind the parameters of the SQL statement or stored procedure. An indispensable object in parametric query.

Tranction

Gets or sets the transaction where the Command object of the. NET Framework data provider is executed.

Common Methods

 

Method

Description

Cancle ()

Its return type is void, canceling Command Execution

CreateParameter ()

The return type is SqlParameter, which is used to create a new instance of the SqlParameter object.

ExecuteNonQuery ()

Execute the operations specified by the CommandText attribute. Generally, they are update, insert, delete, and other SQL commands without return values (such as DDL statements and stored procedures). The number of affected rows is returned, and the type is int. For all other types of statements, the return value is-1.

ExecuteReader ()

Perform the operations specified by the CommandText attribute, create a DataReader object, and return the result set in the SqlDataReader object.

ExecuteScalar ()

The return type of the operation specified by the CommandText attribute is object. The result of this command is returned as an object. Returns the first column of the First row in the execution result set. If no data exists, NULL is returned. It is generally used to execute results such as max, min, Count, and sun.

ExecuteXmlReader ()

The return type is XmlReader. Execute the SELECT statement that returns XML data and use the XmlReader object to return the result set. It is only applicable to the SqlCommand class.

Execute ()

Execute the query, SQL statement, or stored procedure specified in the CommandText attribute of the Command object. If the CommandText attribute specifies the query returned in rows, any results produced by execution will be stored in the new Recordset object. Otherwise, the provider will return the closed Recordset object.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.