Skip to content

Latest commit

 

History

History
42 lines (30 loc) · 2.63 KB

commands-parameters.md

File metadata and controls

42 lines (30 loc) · 2.63 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic
Commands and parameters
Learn how to use Command objects for Microsoft SqlClient Data Provider for SQL Server to run commands and return results from a data source.
David-Engel
v-davidengel
11/25/2020
sql
connectivity
conceptual

Commands and parameters

[!INCLUDEappliesto-netfx-netcore-netst-md]

[!INCLUDEDriver_ADONET_Download]

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 Microsoft SqlClient Data Provider for SQL Server. 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. The Microsoft SqlClient Data Provider for SQL Server has the xref:Microsoft.Data.SqlClient.SqlCommand 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
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 the Microsoft SqlClient data provider for SQL Server to execute stored procedures or data definition language (DDL) statements.

See also