Results 1 to 2 of 2

Thread: Object reference

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2002
    Location
    London
    Posts
    678

    Object reference

    The error is:
    Object reference not set to an instance of an object. (See commented line below-------)
    I tried using the new keyword and that does not solve the problem.
    Do you see the problem?

    Private Sub LoadData(ByVal SortKey As String)

    Dim strPath As String = Server.MapPath(Request.ApplicationPath)
    Dim ds As New DataSet()
    ds.ReadXmlSchema(strPath & "\XML\A.xsd")
    ds.ReadXml(strPath & "\XML\A.xml")

    '----------------This line gives the error----------------------------------------
    Dim view As DataView = ds.Tables("Orders").DefaultView
    '--------------------------------------------------------
    If Not (SortKey Is Nothing) And SortKey <> [String].Empty Then
    view.Sort = SortKey
    End If
    dgUsers.DataSource = view
    dgUsers.DataBind()
    End Sub

  2. #2
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Fort Collins, CO
    Posts
    366
    One problem i see is that you never name a table "Orders" but try to reference it anyway. If you only have one table try referencing ds.Tables(0).DefaultView. Or, ds.Table(0).TableName = "Orders" then use ds.Tables("Orders").DefaultView.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width