PrepAway - Latest Free Exam Questions & Answers

Tag: nocache directive sql server

Which code segment should you insert at line 13?

You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.
You create a Web page that has a GridView control named GridView1. The GridView1 control displays the data from a database named Region and a table named Location.
You write the following code segment to populate the GridView1 control. (Line numbers are included for reference only.)

01Protected Sub Page_Load(sender As Object, e As EventArgs)
02 Dim connstr As String
03
04 SqlDependency.Start(connstr)
05 Using connection As New SqlConnection(connstr)
06 Dim sqlcmd As New SqlCommand()
07 Dim expires As DateTime = DateTime.Now.AddMinutes(30)
08 Dim dependency As New SqlCacheDependency("Region", "Location")
09 Response.Cache.SetExpires(expires)
10 Response.Cache.SetValidUntilExpires(True)
11 Response.AddCacheDependency(dependency)
12 sqlcmd.Connection = connection
13
14 GridView1.DataSource = sqlcmd.ExecuteReader()
15 GridView1.DataBind()
16 End Using
17 End Sub

You need to ensure that the proxy servers can cache the content of the GridView1 control.
Which code segment should you insert at line 13?