Permalink
Fetching contributors…
Cannot retrieve contributors at this time
44 lines (36 sloc) 3.36 KB
title ms.custom ms.date ms.prod ms.reviewer ms.suite ms.technology ms.tgt_pltfrm ms.topic ms.assetid caps.latest.revision author ms.author manager
Commands and Parameters
03/30/2017
.net-framework
dotnet-ado
article
b623f810-d871-49a5-b0f5-078cc3c34db6
3
JennieHubbard
jhubbard
jhubbard

Commands and Parameters

After establishing a connection to a data source, you can execute commands and return results from the data source using a xref:System.Data.Common.DbCommand object. You can create a command using one of the command constructors for the .NET Framework data provider you are working with. Constructors can take optional arguments, such as an SQL statement to execute at the data source, a xref:System.Data.Common.DbConnection object, or a xref:System.Data.Common.DbTransaction object. You can also configure those objects as properties of the command. You can also create a command for a particular connection using the xref:System.Data.Common.DbConnection.CreateCommand%2A method of a DbConnection object. The SQL statement being executed by the command can be configured using the xref:System.Data.Common.DbCommand.CommandText%2A property.

Each .NET Framework data provider included with the .NET Framework has a Command object. The .NET Framework Data Provider for OLE DB includes an xref:System.Data.OleDb.OleDbCommand object, the .NET Framework Data Provider for SQL Server includes a xref:System.Data.SqlClient.SqlCommand object, the .NET Framework Data Provider for ODBC includes an xref:System.Data.Odbc.OdbcCommand object, and the .NET Framework Data Provider for Oracle includes an xref:System.Data.OracleClient.OracleCommand object.

In This Section

Executing a Command
Describes the ADO.NET Command object and how to use it to execute queries and commands against a data source.

Configuring Parameters and Parameter Data Types
Describes working with Command parameters, including direction, data types, and parameter syntax.

Generating Commands with CommandBuilders
Describes how to use command builders to automatically generate INSERT, UPDATE, and DELETE commands for a DataAdapter that has a single-table SELECT command.

Obtaining a Single Value from a Database
Describes how to use the ExecuteScalar method of a Command object to return a single value from a database query.

Using Commands to Modify Data
Describes how to use a data provider to execute stored procedures or data definition language (DDL) statements.

See Also

DataAdapters and DataReaders
DataSets, DataTables, and DataViews
Connecting to a Data Source
ADO.NET Managed Providers and DataSet Developer Center