Events
Mar 31, 11 PM - Apr 2, 11 PM
The biggest SQL, Fabric and Power BI learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register todayThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Applies to:
.NET Framework
.NET
.NET Standard
After establishing a connection to a data source, you can execute commands and return results from the data source using a 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 a SQL statement to execute at the data source, a DbConnection object, or a 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 CreateCommand method of a DbConnection
object. The SQL statement being executed by the command can be configured using the CommandText property. The Microsoft SqlClient Data Provider for SQL Server has the SqlCommand object.
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.
Events
Mar 31, 11 PM - Apr 2, 11 PM
The biggest SQL, Fabric and Power BI learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register todayTraining
Learning path
Get Started Querying with Transact-SQL - Training
Get Started Querying with Transact-SQL
Documentation
Executing a command - ADO.NET Provider for SQL Server
Describes the Microsoft SqlClient Data Provider for SQL Server `Command` object and how to use it to execute queries and commands against a data source.
Configuring parameters - ADO.NET Provider for SQL Server
Command objects use parameters to pass values to SQL statements or stored procedures, providing type checking and validation in ADO.NET.
Retrieving and modifying data - ADO.NET Provider for SQL Server
In .NET, Microsoft SqlClient Data Provider for SQL Server serves as a bridge between an application and a data source to read and update data.