Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Urgent Question

  • 28-07-2006 9:35am
    #1
    Registered Users, Registered Users 2 Posts: 6,659 ✭✭✭


    Our company has been written a program and to be honest its a cock up and we need it fixed straight away we are getting a few errors but this one keeps coming up. Anyone share some light?
    [B]Server Error in '/' Application.  [/B]
    
     [B][I]Object reference not set to an instance of an object.[/I]  [/B]
    
    [FONT=Arial, Helvetica, Geneva, SunSans-Regular, sans-serif][B]Description:  [/B]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. 
    
    [B]Exception Details:  [/B]System.NullReferenceException: Object reference not set to an instance of an  object.
    
    [B]Source Error:[/B] 
    
       Line 18:     End Sub
    Line 19:     Private Sub Check_Login()
    [COLOR=red]Line 20:         For Each drLogin As DataRow In dsAgentInfo.Tables(0).Rows
    [/COLOR]Line 21:             If Regex.IsMatch(cmbAgentID.SelectedValue, drLogin("AgentID").ToString()) And Regex.IsMatch(txtPass.Text, drLogin("AgentPassword").ToString()) Then
    Line 22:                 Session.Add("Agent", cmbAgentID.SelectedValue)
    [B]Source  File: [/B]D:\hshome\intercal\callcenterapps.com\website\Login.aspx.vb[B]     Line: [/B]20 
    
    [B]Stack Trace:[/B] 
    
       [NullReferenceException: Object reference not set to an instance of an object.]
       Website_Login.Check_Login() in D:\hshome\intercal\callcenterapps.com\website\Login.aspx.vb:20
       Website_Login.Button1_Click(Object sender, EventArgs e) in D:\hshome\intercal\callcenterapps.com\website\Login.aspx.vb:17
       System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
       System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
       System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102
    
     [/FONT]
    


Comments

  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    As it says one of the objects in the line of code is not referencing any data. Its pointing to a null. Most likely dsAgentInfo is not initialised or contains a null value.

    Run it through debug and see whats happening.


  • Registered Users, Registered Users 2 Posts: 6,659 ✭✭✭PowerHouseDan


    Here is the main problem we are having:
    [B]Server Error in '/' Application.  [/B]
    
     [B][I]Object reference not set to an instance of an object.[/I]  [/B]
    
    [FONT=Arial, Helvetica, Geneva, SunSans-Regular, sans-serif][B]Description:  [/B]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. 
    
    [B]Exception Details:  [/B]System.NullReferenceException: Object reference not set to an instance of an  object.
    
    [B]Source Error:[/B] 
    
       Line 214:        dtPeopleDetail.Columns.Add("JobTitle")
    Line 215:        dtPeopleDetail.Columns.Add("Email")
    [COLOR=red]Line 216:        For Each dr As DataRow In dsStreamMatchData.Tables(0).Rows 'now for each item no. from item number list for that stream
    [/COLOR]Line 217:            strItemCode = dr("Code").ToString() 'find the item code 
    Line 218:            For Each drPeople As DataRow In dsPeopleData.Tables(0).Rows ' for each people record
    [B]Source  File: [/B]D:\hshome\intercal\callcenterapps.com\website\Company.aspx.vb[B]     Line: [/B]216 
    
    [B]Stack Trace:[/B] 
    
       [NullReferenceException: Object reference not set to an instance of an object.]
       Company.FillPeopleData(String strSerial) in D:\hshome\intercal\callcenterapps.com\website\Company.aspx.vb:216
       Company.CompanyInfo() in D:\hshome\intercal\callcenterapps.com\website\Company.aspx.vb:125
       Company.Page_Load(Object sender, EventArgs e) in D:\hshome\intercal\callcenterapps.com\website\Company.aspx.vb:26
       System.Web.UI.Control.OnLoad(EventArgs e) +99
       System.Web.UI.Control.LoadRecursive() +47
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061
    
    [/FONT]
    


  • Closed Accounts Posts: 3,357 ✭✭✭Beano


    run it though the debugger and see what values are actually in dsStreamMatchData.Tables(0).Rows. By the looks of it it is null.


  • Registered Users, Registered Users 2 Posts: 6,659 ✭✭✭PowerHouseDan


    But the problem is it works for maybe 5 min and then that error will come up and all the fields are blank...


  • Registered Users, Registered Users 2 Posts: 932 ✭✭✭yossarin


    are there any item no. records in the item number list for that stream ?

    maybe whoever developed never considered that the list could be empty ?
    can you look directly in the database ?


  • Advertisement
  • Moderators, Society & Culture Moderators Posts: 9,689 Mod ✭✭✭✭stevenmu


    Then the error could be whereever you populate those tables. Does the query you use get built up from info stored in session variables by any chance ?


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    But the problem is it works for maybe 5 min and then that error will come up and all the fields are blank...

    The error message that is important is.. "Object reference not set to an instance of an object"

    Now on the line...

    For Each dr As DataRow In dsStreamMatchData.Tables(0).Rows

    The bits in bold are most likely to cause that error (AFAIR). I am not sure about VB but Java wouldn't cause an error on dr being null as you could assign an object to a null. Likewise with Rows. It wouldn't throw the error there but in the loop itself.

    Tables(0) on the other hand is attempting to call a variable, and if Tables(0) was null this would throw this kind of error as you can't read a variable off a null.

    So I will guess and say the problem is that Tables(0) is coming in Null at some point. You should put code in to check to ensure this is not null before executing that code.


  • Registered Users, Registered Users 2 Posts: 15,443 ✭✭✭✭bonkey


    before the following line:

    For Each dr As DataRow In dsStreamMatchData.Tables(0).Rows

    add in some debugging code to do teh dollowing:

    if (null == dsStreamMatchData) {
    generate output to say the ds is null
    }
    else if (null == dsStreamMatchDate.Tables) {
    generate output to say ds has no tables collection
    }
    else if (0 == dsStreamMatchDate.Tables.Count) {
    generate output to say ds has no tables in its tables collection, and thus tables(0) doesn't exist
    }

    This will tell you *what* is broken. My guess is that it won't be the middle one. So either the ds itself isn't initialised, or its not populated.

    Once you know which of those two it is, you can track down *why* its been emptied / not populated / dereferenced / whatevered.


  • Registered Users, Registered Users 2 Posts: 1,193 ✭✭✭liamo


    I reckon either dsStreamMatchData is NULL or dsStreamMatchData.Tables(0) is NULL.

    Have you filled dsStreamMatchData?


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    if (null == dsStreamMatchData) {

    wee bit off topic but that looks like not the norm for the coding convention.

    Expected value should be second, or is a reason you do that?


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 1,391 ✭✭✭fatherdougalmag


    That's just a quirky coding style. Could never understand it myself but there are people out there who like doing that.


  • Closed Accounts Posts: 234 ✭✭nagero


    That's just a quirky coding style. Could never understand it myself but there are people out there who like doing that.

    It's a convention that stops you accidentially doing
    if(variable = null) instead of if(variable == null)
    

    and null'ing out the variable where you really just wanted to test it.
    if(null = variable)
    
    won't compile.

    Real PITA error to track down coz your brain keeps reading the = as ==

    nagero


  • Closed Accounts Posts: 8,478 ✭✭✭GoneShootin


    Did your company not send a barrage of abuse down to the developers?


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    nagero wrote:
    It's a convention that stops you accidentially doing

    You should never ever code an if statement with one equals though.

    Its prob a VB/c/c++ thing as in Java the if statement can only ever equate to a boolean and "var = null" would not compile.


  • Registered Users, Registered Users 2 Posts: 6,659 ✭✭✭PowerHouseDan


    What the Actual problem as is we started getting another error cant remember off the top of my head what was happening is that everytime i did anything with the program it made a connection, at 1 stage me being the only one using the program there was 107 connections so when those connections were dumped due to inactivitiy it started to work again.


Advertisement