locked
No data exists for the row/column RRS feed

  • Question

  • User-51574684 posted

    I am having a slight problem with a feature I am trying to get working on a website I am doing. I keep getting the "No data exists for the row/column" error. And the problem appears to be with this line of code:

     

     LblVisitedHeader.Text = visitor("Name") & " has visited the following students (" & Repeater1Visited.Items.Count & ")" 


     

    Here is my full code:

    Imports System.Data.OleDb
    
    Partial Class Admin_VisitorPreviousVisits
        Inherits System.Web.UI.Page
    
    
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If Session("Name") = Nothing Then
                Response.Redirect("Login.aspx")
            End If
            Session("Name") = Session("Name")
            Session("Username") = Session("Username")
    
            Dim visitor As OleDbDataReader = Database.DoSQLReturnDataReader("SELECT * FROM Visitors WHERE ID=" & Replace(Request.QueryString("ID"), "'", "''"))
    
            If visitor.Read Then
                LblHeaderName.Text = visitor("Name")
                LblID.Text = visitor("ID")
                LblName.Text = visitor("Name")
                LblNameEmpty.Text = visitor("Name")
                LblUsername.Text = visitor("Username")
                LblPassword.Text = visitor("Password")
                LblEmail.Text = visitor("EmailAddress")
                LblTel.Text = visitor("Ext")
            Else
                Response.Redirect("index.aspx?Yr=" & Replace(Request.QueryString("Yr"), "'", "''"))
            End If
    
    		visitor.close()
    
            Dim visited As OleDbDataReader = Database.DoSQLReturnDataReader("SELECT Student.StudentNo, Student.FirstName+' '+Student.Surname AS FirstSurname, Company.CompanyName, Company.Location, StudentPlacementVisit.ExpectedVisitDate, StudentPlacementVisit.ActualVisitDate, StudentPlacementVisit.FurtherVisitRequired, StudentPlacementVisit.Visitor, Visitors.Name, Company.Town, Student.Visited, PlacedStudents.StartDate, DateAdd('m',3,PlacedStudents.StartDate) AS VisitRange1, DateAdd('m',6,PlacedStudents.StartDate) AS VisitRange2 FROM Visitors INNER JOIN ((Student INNER JOIN (Company INNER JOIN PlacedStudents ON Company.[CompanyCode] = PlacedStudents.[CompanyCode]) ON Student.[StudentNo] = PlacedStudents.[StudentNo]) INNER JOIN StudentPlacementVisit ON Student.[StudentNo] = StudentPlacementVisit.[StudentNo]) ON Visitors.ID = StudentPlacementVisit.Visitor WHERE (((StudentPlacementVisit.FurtherVisitRequired)=False) AND ((StudentPlacementVisit.Visitor)=" & Replace(Request.QueryString("ID"), "'", "''") & ") AND ((Student.Visited)=True)) ORDER BY StudentPlacementVisit.ActualVisitDate DESC")
    
            Repeater1Visited.DataSource = visited
            Repeater1Visited.DataBind()
            LblVisitedHeader.Text = visitor("Name") & " has visited the following students (" & Repeater1Visited.Items.Count & ")"
            visited.Close()
    
            If Repeater1Visited.Items.Count = 0 Then
                divVisited.Visible = False
            Else
                divEmpty.Visible = False
            End If
    
        End Sub
    
    End Class
    
    


     

    Any help would be greatly appreciated, thanks.

    Tuesday, August 17, 2010 10:42 AM

Answers

  • User-1199946673 posted

    I keep getting the "No data exists for the row/column" error
     

    Let me help you

    What value does this column have in the database?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 17, 2010 1:26 PM

All replies

  • User-1199946673 posted

    I keep getting the "No data exists for the row/column" error
     

    Let me help you

    What value does this column have in the database?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 17, 2010 1:26 PM
  • User-51574684 posted

    Sorry about the delay replying to this message, I had to leave this project for a while due to other comitments. I have tried bing'ing it with no sucess, the value for the column is a text field which holds the name of the visitor, I have over 50 visitors in the database.

    Thanks

    Tuesday, September 21, 2010 7:40 AM
  • User-1199946673 posted

    Start by using parameterized queries, because I'm not sure why you're replacing single quotes with 2 single quotes:

    http://www.mikesdotnetting.com/Article/26 

    Tuesday, September 21, 2010 11:08 AM