Monday, 21 September 2015

ADO.Net Multiple Choice Questions And Answers

21. You need to retrieve only schema information about the columns contained in a database table without retrieving data. Which of the following is the best way to retrieve it
A. Use the GetSchemaTable() method of the DataReader in conjunction withCommandBehaviour.SchemaOnly
B. Use the SchemaOnly property of the Command class
C. Use the GetSchemaOnly() method of the DataReader
D. You cannot retrieve only schema information without retrieving data
Ans: A

22. Consider the following example
<Script Runat="Server">
Dim intNextNum As Integer
Sub Page_Load
lblMessage1.DataBind()
lblMessage2.DataBind()
DataBind()
End Sub

Function GetNext() As String
intNextNum += 1
Return intNextNum
End Function
</Script>

<html>
<head><title>DataBindTest2.aspx</title></head>
<body>
<form Runat="Server">
<asp:Label ID="lblMessage1" Text='<%# GetNext() %>' Runat="Server" />
<asp:Label ID="lblMessage2" Text='<%# GetNext() %>' Runat="Server" />
</form>
</body>
</html>

23.What will be the values assigned to the two Label controls lblMessage1 & lblMessage2 respectively
A. 2 & 3
B. 3 & 3
C. 3 & 4
D. 4 & 4
Ans: C

23. You need to customize the display format of the DataList control 
A. Set the DisplayFormat property of the DataList control to Custom
B. Set the CustomFormat property of the DataList control to True
C. ItemTemplate will allow you to format the appearance of each DataList item
D. The display format of the DataList control is predefined and cannot be customized
Ans: C

24. You have a DataList control containing a LinkButton. What would you do to raise theDeleteCommand event in the DataList by clicking on the LinkButton.
A. Set CommandName="delete" in the LinkButton
B. Set the OnDelete property of the DataList to the ID of the LinkButton
C. A DataList control cannot raise an event in response to events raised by its child controls
D. A DataList control cannot contain child controls
Ans: A

25. The Products table has a column named ProductName and a primary key column namedProductID. When a user selects an item in the DataList, you want to retrieve the value of theProductID column associated with it.
A. In the DataList control set PrimaryKeyField="ProductID"
B. In the DataList control set DataKeyField="ProductID"
C. In the DataList control set KeyField="ProductID"
D. In the DataList control set ID="ProductID"
Ans: B

26. You need to enable paging for a DataGrid control
A. You can use a DataReader
B. You can use a DataTable
C. You can use either the DataReader or DataTable
D. A DataGrid does not support paging
Ans: B

27. Can you use a DataView to filter rows in a DataTable
A. Yes, by setting the Filter property of the DataView
B. Yes, by setting the RowFilter property of the DataView
C. Yes, by using the SetFilter() method of the DataView
D. No, a DataView cannot be used to filter rows in a DataTable
Ans: B

28. Which statement is an accurate description of the code below (dtsDataset is a DataSet)
Cache("myCachedDataSet") = dstDataset
a. Adds a DataSet to the application's cache in the server's memory, automatically preserving it between page requests.
b. Adds a DataSet to the cache in the client's memory, automatically preserving it between page requests.
c. The Cache object cannot be used to cache a DataSet, it can only cache a DataTable
d. The code block is syntactically incorrect and should actually be
Set Cache("myCachedDataSet") = dstDataset
Ans: A

29. How can you load an XML file directly into a DataSet
A. By setting the XML property of the DataSet class
B. By using the GetXML() method of the DataSet class
C. By using the ReadXml() method of the DataSet class
D. You cannot load an XML file directly into a DataSet
Ans: C

30. Your site has been restructured and the paths of few pages have changed. Which method would you use to redirect users requesting for a pages using the old URL
A. Create an ISAPI filter to do the above task
B. Create an entry in the <badlinks> section of the Web.Config file
C. Use the Application.Config file
D. Handle the Application_BeginRequest event and use the RewritePath() method
Ans: D

More Questions & Answers:-
Page1 Page2 Page3 Page4 Page5 Page6 Page7

1 comment: