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)