Winform+ado.net Application (i)

Source: Internet
Author: User

Goal:

What is ado.net Connection object

Command object

DataReader objects

Demo

What is ado.net:

Ado. NET is Microsoft's newest data access technology, which is improved by Microsoft's ActiveX data Objects (ADO).

Connection object:

The Connection object represents the connection to the data source. You can specify the type, location, and other properties of the data source by using its various properties to make a connection or disconnect from the database. Our common approach is to use the database link string as a parameter directly in its construction method, and to instantiate the object.

Ways to Connection objects:

The open () method is used to open a database connection

The close () method closes the database connection

Command object:

An SQL statement or stored procedure executed on a data source. The command contains the information submitted to the database and is implemented by provider-specific classes such as SqlCommand. Commands can be stored procedure calls, UPDATE statements, and statements that return results.

Method of Command object:

The ExecuteNonQuery () method executes statements such as INSERT, Delele, UPDATE, and returns the number of rows affected.

ExecuteReader () method to return a read-only result set

The ExecuteScalar () method returns the value of the first row of the execution result

DataReader object:

DataReader reads a forward-only and read-only stream of data from the data source. Note: It is not generally necessary to create SqlDataReader objects or OleDbDataReader objects directly, but rather to get them by calling the ExecuteReader () method of the SqlCommand object or OleDbCommand object.

Ways to DataReader objects:

Close () method: Closes the SqlDataReader object

Read () Method: Move the SqlDataReader object to the next record

GetName () Method: Gets the name of the specified column

GetValue () Method: Returns the value of the specified column in local format

Cases:

(Figure 1)

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.