Follow the below steps to work with the command object.
Step 1: Declare the Command Object.
Syntax
[csharp]ClassName ObjectName;[/csharp]
Examples
[csharp]SqlCommand cmd;[/csharp]
Step 2: Define the Command Object.
Syntax
[csharp]ObjectName = new ClassName(string CommandText,Conection)[/csharp]
Examples
[csharp]cmd = new SqlCommand("delete empdetails where eid=101",con)[/csharp]
Step 3: Mention the CommandType.
Syntax
[csharp]ObjectName.CommandType = CommandType.Value;[/csharp]
Examples
[csharp]cmd.CommandType = CommandType.Text;[/csharp]
Step 4: Execute the Command Object.
Syntax
[csharp]ObjectName.Executemethod();[/csharp]
Examples
[csharp]cmd.ExecuteNonQuery();[/csharp]