Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 18th, 2005, 05:39 PM
Registered User
 
Join Date: Jan 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Object reference not set to an instance of an obje

I continue to get the same error message below:
--------------------------------------------------

[NullReferenceException: Object reference not set to an instance of an object.]
   PackageDocuments.PCKDOC_Packages_New.FormatDataTab le(DataTable aobjDTData) in C:\SSE Source\Nationwide_Dev\PackageDocuments\PCKDOC_Pack ages_New.aspx.vb:228
   PackageDocuments.PCKDOC_Packages_New.btnSearch_Cli ck(Object sender, EventArgs e) in C:\SSE Source\Nationwide_Dev\PackageDocuments\PCKDOC_Pack ages_New.aspx.vb:126
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
   System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument) +57
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +18
   System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
   System.Web.UI.Page.ProcessRequestMain() +1263
--------------------------------------------------
Here are the VB.net source code lines.
Line 126:
--------------------------------------------------
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
        Dim lobjDSDocuments As DataSet
        Dim lobjDSSearchCriteria As DataSet
        Dim lintRowCount As Integer
        Dim lobjItem As DataGridItem
        Dim lstrURL As String

        If ValidateDateFields() Then
            lblSrchMessage.Text = ""
            lobjDSSearchCriteria = getDSSearchFields()
            lobjDSDocuments = mobjDocumentPackageSrvc.getDSDocuments
(lobjDSSearchCriteria)
line(126): DocSrchResults.DataSource = FormatDataTable(lobjDSDocuments.Tables.Item("DOCUM ENTS"))
            DocSrchResults.DataBind()

            lstrURL = ConfigurationSettings.AppSettings("DOCLINK.URL")
            For Each lobjItem In DocSrchResults.Items
                Dim lobjLinkItem As LinkButton
                Dim lstrDocID As String
                lobjLinkItem = CType(lobjItem.FindControl("cmdLinkDocument"), LinkButton)
                lstrDocID = lobjLinkItem.Text
                lobjLinkItem.Attributes.Add("onclick", "open_window('" + lstrURL + "&id=" + lstrDocID + "');")
            Next

            lintRowCount = lobjDSDocuments.Tables.Item("DOCUMENTS").Rows.Coun t
            If lintRowCount > 0 Then
                lblSrchMessage.Text = Convert.ToString(lintRowCount) + " Documents Found."
            Else
                lblSrchMessage.Text = "No Documents Found."
            End If
        End If
    End Sub
----------------------------------------------------------------------
Line 228:
----------------------------------------------------------------------
Private Function FormatDataTable(ByVal aobjDTData As DataTable) As DataTable
        Dim lobjDTDocument As New DataTable
        Dim lobjDataColumn As DataColumn
        Dim lobjDataRow As DataRow
        Dim lobjNewRow As DataRow
        Dim lstrDate As String

        lobjDTDocument.Columns.Add(New DataColumn("Document_ID", GetType(String)))
        lobjDTDocument.Columns.Add(New DataColumn("Name", GetType(String)))
        lobjDTDocument.Columns.Add(New DataColumn("Description", GetType(String)))
        lobjDTDocument.Columns.Add(New DataColumn("Active_Date", GetType(String)))
        lobjDTDocument.Columns.Add(New DataColumn("Inactive_Date", GetType(String)))
        lobjDTDocument.Columns.Add(New DataColumn("Document_Date", GetType(String)))
        lobjDTDocument.Columns.Add(New DataColumn("Business_Unit", GetType(String)))

line(228) : For Each lobjDataRow In aobjDTData.Rows lobjNewRow = lobjDTDocument.NewRow
            lobjNewRow.Item("Document_ID") = lobjDataRow.Item("Document_ID")
            lobjNewRow.Item("Name") = lobjDataRow.Item("Name")
            lobjNewRow.Item("Description") = lobjDataRow.Item("Description")

            lstrDate = Trim(lobjDataRow.Item("Active_Date").ToString)
            lobjNewRow.Item("Active_Date") = ConvertDateTime(lstrDate)
            lstrDate = ""

            lstrDate = Trim(lobjDataRow.Item("Inactive_Date").ToString)
            lobjNewRow.Item("Inactive_Date") = ConvertDateTime(lstrDate)
            lstrDate = ""

            lstrDate = Trim(lobjDataRow.Item("Document_Date").ToString)
            lobjNewRow.Item("Document_Date") = ConvertDateTime(lstrDate)
            lstrDate = ""

            'lobjNewRow.Item("Active_Date") = Format(lobjDataRow.Item("Active_Date").ToString, "MM/dd/yyyy")
            'lobjNewRow.Item("Inactive_Date") = Format(lobjDataRow.Item("Inactive_Date").ToString, "MM/dd/yyyy")
            'lobjNewRow.Item("Document_Date") = Format(lobjDataRow.Item("Document_Date").ToString, "MM/dd/yyyy")
            lobjNewRow.Item("Business_Unit") = lobjDataRow.Item("Business_Unit")
            lobjDTDocument.Rows.Add(lobjNewRow)
        Next
        FormatDataTable = lobjDTDocument
    End Function






Similar Threads
Thread Thread Starter Forum Replies Last Post
Object reference not set to an instance of an obje GS C# 2005 3 May 21st, 2007 10:11 AM
Object reference not set to an instance of an obje rturner003 ASP.NET 2.0 Professional 0 December 26th, 2006 08:30 PM
Object reference not set to an instance of an obje bekim Classic ASP Basics 1 August 9th, 2004 01:25 AM
Object reference not set to an instance of an obje DolphinBay VB.NET 2002/2003 Basics 6 June 28th, 2004 03:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.