This article explains the basic details of ADO.NET Part 2.
This article explains the basic details of ADO.NET Part 2.Read here my first article of ADO.NET Part 1:
Introduction To ADO.NETThe methods of the Command Class are:
Note: After creating an object of the command class we need to call any of these 3 methods to execute the statements.
Let's see the details of all these methods.1. Call ExecuteReader ( )The method when we want to execute a “Select statement” that returns data as rows and columns. The method returns an object of the Data Reader class that contains data retrieved from a Data Source in the format of rows and columns.
2. Call ExecuteScaler ( )
The method when we want to execute a “Select Statement ” that returns a “single” value result. The method returns the results of the query in the form of an object.3. Call ExecuteNonQuery
This method call when we want to execute any statement other than a select, like insert, update, delete and so on. This method returns a numeric value telling the number of rows affected by the statements. Accessing Data From DataReader DataReader is a class that holds data as rows and coloums to access data from the DataReader.
It provides the following methods:
Features of Data Reader
For example:Command cmd=new Command(“Select * From Student ; Select * From Mark ”, Con);Data Reader dr= cmd.ExecuteReader();
Note: use the “NextResult()” method of the DataReader object to navigate from the current table to the next table.For example:
Dr.NextResult();Drawbacks of DataReader:
Previous article: Introduction To ADO.NET
For more articles visit my blog:
dotnetbyabhipatil
Pro WPF: Windows Presentation Foundation in .NET 3.0