You work as a Windows Application Developer for ABC Inc. The company uses Visual Studio .NET as its application development platform. You create a Windows application using the .NET Framework.
You create a database to maintain the record of the students. You create a table named Student. You want to retrieve names and roll number of those students whose age is less than ten years. An instance of the SqlCommand class named StudentCommand is already created.
Which of the following code segments should you use to execute the query?
A . StudentCommand.CommandType = CommandType.StoredProcedure; StudentCommand.CommandText = "Name and Roll number of students less than ten years";
B . StudentCommand.CommandType = CommandType.StoredProcedure;
StudentCommand.CommandText = "SELECT Name, Roll number FROM Student WHERE
Age <10";
C . StudentCommand.CommandType = CommandType.Text;
StudentCommand.CommandText = "SELECT Name, Roll number FROM Student WHERE
Age <10";
D . StudentCommand.CommandText = CommandText.Text;
StudentCommand.CommandType = "SELECT Name, Roll number FROM Student WHERE
Age <10";
Answer: C