Null Exception error - Kindly help me

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • muralidharan

    Null Exception error - Kindly help me

    WebForm1.aspx Code:

    <%@ Register TagPrefix="Comp onentArt" Namespace="Comp onentArt.Web.UI "
    Assembly="Compo nentArt.Web.UI" %> <ComponentArt:T reeView
    id="TreeView1" Height="520" AutoPostBackOnN odeMove="false"
    DragAndDropEnab led="true"
    NodeEditingEnab led="False" KeyboardEnabled ="true"
    CssClass="TreeV iew" NodeCssClass="T reeNode"
    SelectedNodeCss Class="Selected TreeNode"
    HoverNodeCssCla ss="HoverTreeNo de" NodeEditCssClas s="NodeEdit"
    LineImageWidth= "19" LineImageHeight ="20"
    DefaultImageWid th="16" DefaultImageHei ght="16" ItemSpacing="0"
    NodeLabelPaddin g="3" SpacerImageUrl= "/MRCSWebApp/Images/spacer.gif"
    CollapseImageUr l="/MRCSWebApp/Images/exp.gif"
    ExpandImageUrl= "/MRCSWebApp/Images/col.gif"
    ParentNodeImage Url="/MRCSWebApp/Images/folders.gif"
    LeafNodeImageUr l="/MRCSWebApp/Images/folder.gif"
    ShowLines="true " LineImagesFolde rUrl="/MRCSWebApp/Images/lines/"
    EnableViewState ="true"
    ClientScriptLoc ation="~/client_scripts/componentart_we bui_client/"
    runat="server"> </ComponentArt:Tr eeView>


    BackEnd Code:

    Imports MRCS_Class.File Utilities
    Imports System.Data
    Imports System.Data.Sql Client
    Imports System.Data.Sql Types
    Imports System.Data.Ole Db
    Imports MRCS_Class.Logi nClass
    Imports MRCSWebApp.Welc ome
    Imports System.Data.Sql DbType
    Imports System
    Imports System.Collecti ons
    Imports System.Componen tModel
    Imports System.Drawing
    Imports System.Web
    Imports System.Web.Sess ionState
    Imports System.Web.UI
    Imports System.Web.UI.W ebControls
    Imports System.Web.UI.H tmlControls
    Imports MRCS_Class.Sear ch
    Imports ComponentArt.We b.UI
    Public Class AdvancedSearch
    Inherits System.Web.UI.P age
    Public objDataReader As IDataReader

    #Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnos tics.DebuggerSt epThrough()> Private Sub
    InitializeCompo nent()

    End Sub
    Protected WithEvents TreeView1 As ComponentArt.We b.UI.TreeView
    Protected WithEvents MRN As System.Web.UI.W ebControls.Text Box
    Protected WithEvents SSN As System.Web.UI.W ebControls.Text Box
    Protected WithEvents Lname As System.Web.UI.W ebControls.Text Box
    Protected WithEvents Fname As System.Web.UI.W ebControls.Text Box
    Protected WithEvents DOB As System.Web.UI.W ebControls.Text Box
    Protected WithEvents AdvancedGrid As
    System.Web.UI.W ebControls.Data Grid
    Protected WithEvents AdvSearch As System.Web.UI.W ebControls.Butt on

    'NOTE: The following placeholder declaration is required by the
    Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceho lderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
    System.EventArg s) Handles MyBase.Init
    'CODEGEN: This method call is required by the Web Form
    Designer
    'Do not modify it using the code editor.
    InitializeCompo nent()
    End Sub

    #End Region
    Dim oConn As SqlConnection
    Dim objReader As IDataReader
    Public UserID As Int16
    Dim FetchType As String
    Dim oDS As New DataSet
    Dim DView As DataView
    Dim MenuID As Integer
    Dim MenuProfileID As Integer

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArg s) Handles MyBase.Load
    'Put user code to initialize the page here
    ' If Not IsPostBack = True Then
    ID = Request("GUID")
    Login(ID)
    ' End If
    End Sub
    Public Sub Login(ByVal GID)

    Try
    Dim objCon As New SqlConnection(" Initial Catalog=MRCS;
    Data Source=DEVBOX;u id=devuser;pwd= xxxx")
    objCon.Open()
    ' Set Command object properties
    Dim objCmd As New SqlCommand
    Dim objCmd1 As New SqlCommand
    With objCmd
    .Connection = objCon
    .CommandText = "procLogin_Retr eiveSession"
    .CommandType = CommandType.Sto redProcedure
    .Parameters.Add ("@SESSIONID ", SqlDbType.VarCh ar,
    255).Value = GID
    End With
    objReader = objCmd.ExecuteR eader
    objReader.Read( )
    If Not objReader.IsDBN ull(0) Then
    UserID = objReader.GetVa lue(0)
    End If
    objReader.Close ()

    With objCmd1
    .Connection = objCon
    .CommandText = "procProfileDet ail_Retreive"
    .CommandType = CommandType.Sto redProcedure
    .Parameters.Add ("@UserID", SqlDbType.BigIn t).Value =
    UserID
    End With
    objDataReader = objCmd1.Execute Reader
    objDataReader.R ead()
    If Not objDataReader.I sDBNull(0) Then
    MenuProfileID = objDataReader.G etValue(0)
    End If

    buildTree(MenuP rofileID)


    Catch ex As Exception
    Dim clsError As MRCS_Class.File Utilities
    clsError = New MRCS_Class.File Utilities
    With clsError
    .CreateErrorLog (Err.Number, Err.Description )
    End With
    End Try
    End Sub
    ' Build Tree, Populate Sub Tree and Create Node are Used to create
    the tree
    Private Sub buildTree(ByVal MenuProfileID)

    Dim dbCon As New SqlConnection(" Initial Catalog=MRCS; Data
    Source=DEVBOX;u id=devuser;pwd= xxxxx")
    dbCon.Open()

    Dim adapter As New SqlDataAdapter( "SELECT * FROM tblMenu LEFT
    OUTER JOIN tblMenuProfileD etails ON tblMenu.MenuID =
    tblMenuProfileD etails.MenuID WHERE tblMenuProfileD etails.MenuProf ileID
    =" & MenuProfileID & "OR tblMenu.ParentN odeID IS NULL OR
    tblMenu.ParentN odeID = 1 ORDER BY tblMenu.MenuID ASC", dbCon)
    Dim ds As New System.Data.Dat aSet
    adapter.Fill(ds )
    ds.Relations.Ad d("NodeRelation ",
    ds.Tables(0).Co lumns("MenuID") , ds.Tables(0).Co lumns("ParentNo deID"))
    Dim dbRow As System.Data.Dat aRow
    For Each dbRow In ds.Tables(0).Ro ws
    If (dbRow.IsNull(" ParentNodeID")) Then
    Dim newNode As ComponentArt.We b.UI.TreeViewNo de
    newNode = CreateNode(dbRo w("Text").ToStr ing(),
    dbRow("ImageURL ").ToString (), dbRow("RefURL") .ToString(), True)
    TreeView1.Nodes .Add(newNode)
    PopulateSubTree (dbRow, newNode)
    End If
    Next dbRow

    End Sub
    ' Build Tree, Populate Sub Tree and Create Node are Used to create
    the tree
    Private Sub PopulateSubTree (ByVal dbRow As System.Data.Dat aRow,
    ByVal node As ComponentArt.We b.UI.TreeViewNo de)
    Dim childRow As System.Data.Dat aRow
    For Each childRow In dbRow.GetChildR ows("NodeRelati on")
    Dim childNode As ComponentArt.We b.UI.TreeViewNo de
    childNode = New ComponentArt.We b.UI.TreeViewNo de
    childNode = CreateNode(chil dRow("Text").To String(),
    childRow("Image URL").ToString( ), childRow("RefUR L").ToString (), True)
    node.Nodes.Add( childNode)
    PopulateSubTree (childRow, childNode)
    Next childRow
    End Sub
    ' Build Tree, Populate Sub Tree and Create Node are Used to create
    the tree
    Private Function CreateNode(ByVa l text As String, ByVal imageurl
    As String, ByVal refurl As String, ByVal expanded As Boolean) As
    ComponentArt.We b.UI.TreeViewNo de
    Dim MsgID As Integer
    Dim PID As Integer
    Dim MsgType As String
    Dim node As ComponentArt.We b.UI.TreeViewNo de
    node = New ComponentArt.We b.UI.TreeViewNo de
    node.Text = text
    node.ImageUrl = imageurl
    node.Expanded = expanded
    node.NavigateUr l = refurl & "?MsgID=" & Request("MsgID" ) &
    "&PID=" & Request("PID") & "&MsgType=" & Request("MsgTyp e") & "&GUID="
    & Request("GUID")

    Return node
    End Function

    This returns a error as below:

    Server Error in '/MRCSWebApp' Application.
    --------------------------------------------------------------------------------

    Object reference not set to an instance of an object.
    Description: An unhandled exception occurred during the execution of
    the current web request. Please review the stack trace for more
    information about the error and where it originated in the code.

    Exception Details: System.NullRefe renceException: Object reference not
    set to an instance of an object.

    Source Error:

    An unhandled exception was generated during the execution of the
    current web request. Information regarding the origin and location of
    the exception can be identified using the exception stack trace below.

    Stack Trace:


    [NullReferenceEx ception: Object reference not set to an instance of an
    object.]
    System.Web.UI.C ontrol.FindCont rol(String id, Int32 pathOffset) +178
    System.Web.UI.C ontrol.FindCont rol(String id) +9
    ComponentArt.We b.UI.BaseNaviga tor.UpdateSelec tedNode() +127
    ComponentArt.We b.UI.BaseNaviga tor.OnLoad(Even tArgs e) +290
    ComponentArt.We b.UI.TreeView.O nLoad(EventArgs e) +19
    System.Web.UI.C ontrol.LoadRecu rsive() +35
    System.Web.UI.C ontrol.LoadRecu rsive() +98
    System.Web.UI.C ontrol.LoadRecu rsive() +98
    System.Web.UI.P age.ProcessRequ estMain() +731


    Kindly help me out.
    Thank you
    Murali.
Working...