Command object property settings to execute stored procedure - ADO.NET

Q.  What are the Command object property settings to execute a stored procedure?

1. CommandType = Text, CommandText = stored procedure name
2. CommandType= Text, CommandText = SQL syntax to execute the stored
procedure
3. CommandType = StoredProcedure, CommandText = SQL syntax to execute the
stored procedure
4. CommandType = StoredProcedure, CommandText = stored procedure name

- Published on 19 Oct 15

a. 1, 2
b. 1, 2, 3
c. 2, 4
d. 1, 4

ANSWER: 2, 4
 
You can execute stored procedure by using Command object.
SqlCommandcmd = new SqlCommand();
cmd.Connection = ConnectionString;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "stored procedure name ";

Post your comment / Share knowledge


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)