Not displaying all resultshttp://forums.asp.net/t/1799881.aspx/1?Not+displaying+all+resultsFri, 04 May 2012 18:29:53 -040017998814964489http://forums.asp.net/p/1799881/4964489.aspx/1?Not+displaying+all+resultsNot displaying all results <p>I'm working on a gallery that will pull all active visitors to the foundation I work for and associate their information with a photograph. I am spacing them three records per row as this is the easiest to view within our design guidelines. When the SQLDataReader gets to the end of the querry if there are not exactly three records it cuts of all records past the last full row. The code below is actual formating code for the table including my failed attempt to rectify this.</p> <pre class="prettyprint">Try 'connection to SQL database visitorConnection.ConnectionString = &quot;Data Source=SQLtest;Initial Catalog=EmployeeList;uid=IntranetUser;pwd=IntranetUser&quot; visitorConnection.Open() 'SQL querry that preformats visitorName and visitorPhoto for filename search 'needs to be replaced with a stored procedure at a later date visitorQuery = &quot;SELECT [LastName],[FirstName],[Department],[Supervisor],[Phone Number],[Extension],[EmailAddress] FROM [EmployeeList].[dbo].[NonEmployees] WHERE Inactive &lt;&gt; '1' AND LastName &lt;&gt; 'Security' ORDER BY LastName&quot; visitorCommand.CommandText = visitorQuery visitorCommand.CommandType = CommandType.Text visitorCommand.Connection = visitorConnection 'imagePath = System.Configuration.ConfigurationManager.AppSettings.Get(&quot;ImageDirectory&quot;) imagePath = &quot;c:\inetpub\wwwroot\HR\Photos\&quot; visitorReader = visitorCommand.ExecuteReader() Dim cellCounter As Integer = 1 If visitorReader.HasRows Then While visitorReader.Read() ....</pre> <pre class="prettyprint"> 'create the table 'creates new row for table to add cells to If cellCounter = 1 Then tr = New TableRow End If 'creates the cell for the photo, sets it to 11%, adds it to the row, then clears tc tc = New TableCell tc.Width = Unit.Percentage(11) tc.Text = (visitorShowImage) tr.Cells.Add(tc) tc = Nothing 'creates the cell for employee info, sets it to 22%, adds it to the row, then clears tc tc = New TableCell tc.Width = Unit.Percentage(22) tc.Text = visitorContent tr.Cells.Add(tc) tc = Nothing 'adds the row to the table after 3 records are cycled If cellCounter = 3 Then Me.tblVisitor.Rows.Add(tr) tr = Nothing End If 'loops through the records 3 times and then resets the counter If cellCounter &lt;&gt; 3 Then cellCounter += 1 Else cellCounter = 1 End If End While 'ElseIf visitorReader.HasRows = False Then ' If cellCounter &lt;&gt; 3 Then ' tc = New TableCell ' tc.Width = Unit.Percentage(33) ' tc.Text = "&amp;nbsp" ' tr.Cells.Add(tc) ' tc = Nothing ' cellCounter += 1 ' Else ' Me.tblVisitor.Rows.Add(tr) ' tr = Nothing ' End If End If visitorReader = Nothing visitorCommand = Nothing visitorConnection.Close() visitorConnection.Dispose() Catch ex As Exception HandleError(ex, HttpContext.Current, True, "") End Try End Sub End Class</pre> <p><br> <br> </p> <p>Can anyone easily see what it is I'm doing wrong or simply not doing?</p> 2012-05-03T21:44:16-04:004966167http://forums.asp.net/p/1799881/4966167.aspx/1?Re+Not+displaying+all+resultsRe: Not displaying all results <p>Fixed it with three lines of code:</p> <pre class="prettyprint">If (visitorReader.Read = False) And (cellCounter &lt; 3) Then Me.tblVisitor.Rows.Add(tr) End If</pre> <p>Just had to take a break and come back to it.<br> <br> </p> 2012-05-04T18:29:53-04:00