Im trying to display three groups of headlines. Each group comes from a different table in the DB. I thought using the nextResult() method might be a good approach, but I cant get it to work. The page loads without any errors, but none of the data is being displayed. Can anyone see what Im doing wrong here, or recommend a better way to do this?
Heres the code:
Heres the code:
Code:
<%@ Page Language="VB" %>
<%@ Register TagPrefix="IAR" TagName="Header" Src="_Headerhome.ascx" %>
<%@ Register TagPrefix="IAR" TagName="Footer" Src="_footer.ascx" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<%@ import Namespace="System.Web.UI.WebControls" %>
<%@ import Namespace="System.Configuration" %>
<script runat="server">
Public Class ManyResults : Inherits System.Web.UI.Page
Protected rptrWhatsNew As HyperLink
Protected rptrLegal As HyperLink
Protected rptrEvents As HyperLink
Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
Dim objConn As SqlConnection
Dim objCmd As SqlCommand
Dim dataReader As SqlDataReader
Dim strSql As String
objConn = New SqlConnection(ConfigurationSettings.AppSettings.Get("ConnectionString"))
strSql = _
"SELECT TOP 3 Left(Title, 27) AS Title, url, id FROM whatsNew ORDER BY id DESC;" _
& "SELECT TOP 3 Left(Title, 27) AS Title, id, CatID FROM legalAffairs WHERE CatID = 1 ORDER BY id DESC;" _
& "SELECT TOP 3 Left(Event, 27) AS Event, id FROM events ORDER BY id DESC;"
objCmd = New SqlCommand(strSql, objConn)
Try
objConn.Open()
dataReader = objCmd.ExecuteReader()
Whats New
With rptrWhatsNew
.NavigateUrl = "url"
.text = "Title"
End With
Legal Headlines
dataReader.NextResult()
With rptrLegal
.text = "Title"
End With
Upcoming Events
dataReader.NextResult()
With rptrEvents
.text = "Event"
End With
Catch exc As Exception
Response.Write(exc)
Finally
If Not dataReader Is Nothing Then
dataReader.Close()
End If
objCmd = Nothing
If objConn.State = ConnectionState.Open Then
objConn.Close()
End If
objConn.Dispose()
End Try
End Sub
End Class
</script>
<html>
<head>
<title>Indiana Association of REALTORS - Members Area</title>
</head>
<body bgcolor="#ffffff" leftmargin="0" topmargin="0">
<form id="Form1" method="post" runat="server">
<table>
<tr>
<td bgcolor="#EEEEEE" align="right">Whats New:</td>
<td><asp:HyperLink runat="server" ID="rptrWhatsNew" NAME="rptrWhatsNew" /></td>
</tr>
<tr>
<td bgcolor="#EEEEEE" align="right">Legal Headlines:</td>
<td><asp:HyperLink NavigateUrl=legal/legalDetail.aspx?id=1 runat="server" ID="rptrLegal" NAME="rptrLegal" /></td>
</tr>
<tr>
<td bgcolor="#EEEEEE" align="right">Upcoming Events:</td>
<td><asp:HyperLink NavigateUrl=association/events/ runat="server" ID="rptrEvents" NAME="rptrEvents" /></td>
</tr>
</table>
</form>
</body>
</html>