070-565 Free Dumps Study Materials
Question 6: You create a Windows Forms application by using Microsoft Visual Studio .NET 2008 and the .NET
Framework 3.5.
The application contains the following code segment.
Public Function GetProductByID(ByVal ProductID As String) As DataSet
Dim ds As DataSet = New DataSet("ProductList")
Dim SqlSelectCommand As String = "Select * FROM PRODUCTS WHERE
PRODUCTID=" + ProductID
Try
Dim da As SqlDataAdapter = New SqlDataAdapter()
Dim cn As SqlConnection = New
SqlConnection(GetConnectionString())
Dim cmd As SqlCommand = New SqlCommand(SqlSelectCommand)
cmd.CommandType = CommandType.Text
cn.Open()
da.Fill(ds)
cn.Close()
Catch ex As Exception
Dim msg As String = ex.Message.ToString()
'Perform Exception Handling Here
End Try
Return ds
End Function
You need to ensure that the code segment is as secure as possible.
What should you do?
A. Ensure that the connection string is encrypted.
B. Use a StringBuilder class to construct the SqlSelectCommand string.
C. Add a parameter to the cmd object and populate the object by using the ProductID string.
D. Replace the SELECT * statement in the SqlSelectCommand string with the SELECT <column list>
statement.
Correct Answer: C