D
D. Shane Fowlkes
(still a .NET newbie)
I have a chunk of code in a Page_Load routine that pulls data from a SQL
Server table. The Select statement looks for any "events" scheduled for
today. Then my IF statement writes some HTML to a asp:label tag and
conditionally fills it with HTML based upon any records were found. Seems
simple huh? It works fine if the recordset is null...or in .NET speak, if
the If Not DataReader.Read()..but when data IS found....nothing happens.
All it writes to the page is literally "<ul></ul>". D'oh!
Could someone spot check this please? It seems fine to me......
'==================================
'Display any events happening today....
Dim strTodayEventsSQL As String
Dim datTodayEvents As SQLDataReader
strHTML = ""
strTodayEventsSQL = "SELECT * FROM IntranetCalendar WHERE CalMonth = " &
Month(Today()) & " AND CalDay = " & Day(Today()) & " AND CalYear = " &
Year(Today()) & " AND Display = 1;"
cmdSQLCommand = New SQLCommand(strTodayEventsSQL, objDbConn)
datTodayEvents = cmdSQLCommand.ExecuteReader()
strHTML = strHTML & "<ul>"
If datTodayEvents.Read() Then
'****NOTHING SEEMS TO HAPPEN HERE*********
While datTodayEvents.Read()
strHTML = strHTML & "<li><a href=" & CHR(34) &
"calendar/default.aspx" & CHR(34) & ">" & datTodayEvents("CalTitle") &
"</a></li>"
End While
Else
strHTML = strHTML & "<li><a href=" & CHR(34) & "calendar/default.aspx"
& CHR(34) & ">There is nothing entered in for today - however, you can add
agency related events to the DRPT Calendar here.</a></li>"
End If
strHTML = strHTML & "</ul>"
lblTodayEvents.Text = strHTML
datTodayEvents.Close()
'==================================
--
*********************************
D. Shane Fowlkes - TMM
Saving the world, one web site at a time.
http://www.shanefowlkes.com
*********************************
I have a chunk of code in a Page_Load routine that pulls data from a SQL
Server table. The Select statement looks for any "events" scheduled for
today. Then my IF statement writes some HTML to a asp:label tag and
conditionally fills it with HTML based upon any records were found. Seems
simple huh? It works fine if the recordset is null...or in .NET speak, if
the If Not DataReader.Read()..but when data IS found....nothing happens.
All it writes to the page is literally "<ul></ul>". D'oh!
Could someone spot check this please? It seems fine to me......
'==================================
'Display any events happening today....
Dim strTodayEventsSQL As String
Dim datTodayEvents As SQLDataReader
strHTML = ""
strTodayEventsSQL = "SELECT * FROM IntranetCalendar WHERE CalMonth = " &
Month(Today()) & " AND CalDay = " & Day(Today()) & " AND CalYear = " &
Year(Today()) & " AND Display = 1;"
cmdSQLCommand = New SQLCommand(strTodayEventsSQL, objDbConn)
datTodayEvents = cmdSQLCommand.ExecuteReader()
strHTML = strHTML & "<ul>"
If datTodayEvents.Read() Then
'****NOTHING SEEMS TO HAPPEN HERE*********
While datTodayEvents.Read()
strHTML = strHTML & "<li><a href=" & CHR(34) &
"calendar/default.aspx" & CHR(34) & ">" & datTodayEvents("CalTitle") &
"</a></li>"
End While
Else
strHTML = strHTML & "<li><a href=" & CHR(34) & "calendar/default.aspx"
& CHR(34) & ">There is nothing entered in for today - however, you can add
agency related events to the DRPT Calendar here.</a></li>"
End If
strHTML = strHTML & "</ul>"
lblTodayEvents.Text = strHTML
datTodayEvents.Close()
'==================================
--
*********************************
D. Shane Fowlkes - TMM
Saving the world, one web site at a time.
http://www.shanefowlkes.com
*********************************