Write a program to execute a stored procedure in ADO.NET?
Filed under: .NET Interview Questions, ADO.NET Interview Questions
using (SqlConnection ConnectionObject = new SqlConnection())
{
//Specify the name of the stored procedure to execute and the Connection Object to use
SqlCommand CommandObject = new SqlCommand(“StoredProcedureName”, ConnectionObject);
//Specify the SQL Command type is a stored procedure
CommandObject.CommandType = CommandType.StoredProcedure;
//Open the connection
ConnectionObject.Open();
//Execute the Stored Procedure
int RecordsAffected = CommandObject.ExecuteNonQuery();
}
What are the methods that can ensure asynchronous execution of the Transact-SQL statement or stored procedure?
Filed under: .NET Interview Questions, ADO.NET Interview Questions, SQL SERVER Interview Questions
BeginExecuteNonQuery
BeginExecuteReader
What is SqlCommand.CommandTimeout Property of ADO.NET used for?
Filed under: .NET Interview Questions, ADO.NET Interview Questions
CommandTimeout Property is used to Get or set the wait time before terminating the attempt to execute a command and generating an error.
//Specify the CommandTimeout property value
SqlCommand CommandObject = new SqlCommand(“StoredProcedureName”, ConnectionObject);
//Wait for 10 seconds to execute the Stored procedure
CommandObject.CommandTimeout = 10;
The time is in seconds. The default is 30 seconds
What is Microsoft ADO.NET?
Filed under: .NET Interview Questions, ADO.NET Interview Questions
Visual Studio .NET provides access to databases through the set of tools and namespaces collectively referred to as Microsoft ADO.NET
