070-565 Free Dumps Study Materials
Question 9: You create an application by using Microsoft Visual Studio .NET 2008 and the .NET Framework 3.5.
The application has a class that contains a method named NewEvent. The NewEvent method contains
the following code segment.
using (SqlConnection cn = new SqlConnection(connString))
{
SqlCommand cmd = new SqlCommand();
cmd.Connection = cn;
cmd.CommandText = "prcEvent";
cmd.Parameters.Add("@Date", SqlDbType.DateTime, 4);
cmd.Parameters.Add("@Desc", SqlDbType.VarChar, 8000);
cmd.Parameters.Add("@Link", SqlDbType.VarChar, 2048);
cmd.Parameters["@Date"].Value = date;
cmd.Parameters["@Desc"].Value = eventText;
cmd.Parameters["@Link"].Value = eventLink;
cn.Open();
retcode = cmd.ExecuteNonQuery().ToString();
}
During the test process, a user executes the NewEvent method. The method fails and returns the
following error message:
"A stored procedure named prcEvent requires a parameter named @Date."
You need to resolve the error.
What should you do?
A. Set the CommandText property of the cmd object to dbo.prcEvent.
B. Set the CommandType property of the cmd object to CommandType.TableDirect.
C. Set the CommandType property of the cmd object to CommandType.StoredProcedure.
D. Replace the ExecuteNonQuery method of the cmd object with the ExecuteScalar method.
Correct Answer: C