C# ADO.NET Command
The Command Object in ADO.NET executes SQL statements and Stored Procedures against the data source specified in the C# Connection Object. The Command Object requires an instance of a C# Connection Object for executing the SQL statements .
In order to retrieve a resultset or execute an SQL statement against a Data Source , first you have to create a Connection Object and open a connection to the Data Source specified in the connection string. Next step is to assign the open connection to the connection property of the Command Object . Then the Command Object can execute the SQL statements. After the execution of the SQl statement, the Command Object will return a result set . We can retrieve the result set using a Data Reader .
The Command Object has a property called CommandText , which contains a String value that represents the command that will be executed against the Data Source. When the CommandType property is set to StoredProcedure, the CommandText property should be set to the name of the stored procedure.
Click the following links to see some important built in methods uses in the Command Object to execute the SQL statements.
- C# ADO.NET Connection
- C# SQL Server Connection
- C# OLEDB Connection
- C# ODBC Connection
- C# ADO.NET SqlCommand - ExecuteNonQuery
- C# ADO.NET OleDbCommand - ExecuteNonQuery
- C# ADO.NET SqlCommand - ExecuteScalar
- C# ADO.NET OleDbCommand - ExecuteScalar
- C# ADO.NET SqlCommand - ExecuteReader
- C# ADO.NET OleDbCommand - ExecuteReader
- C# ADO.NET DataReader
- C# ADO.NET SqlDataReader
- C# ADO.NET OleDbDataReader
- C# Multiple Result Sets
- C# Table Schema from SqlDataReader
- C# Table Schema from OleDbDataReader
- C# ADO.NET DataAdapter
- C# ADO.NET SqlDataAdapter
- C# ADO.NET OleDbDataAdapter
- C# ExecuteReader and ExecuteNonQuery
- System.Data.SqlClient.SqlException: Login failed for user