0

Good day folks...

This may seem like an odd question and I apologize in advance for the limited information to work with in this case but I'll do what I can to give the needed info...

My website http://www.bariby-quance.com has a journal/blog component that I built within it that, on all of the computers in my household and in 3 different browsers (Firefox, IE and Safari) has never once encountered an error.

However, I have had a couple of people tell me they are receiving errors when using the asp.net apps I've built into my site and I can't replicate them. I spoke with technical support at my hosting provider but they don't have server-side error logs they can provide me on their windows server platform. The tech support agent did, however, hit an error after literally hundreds of clicks on the post navigation buttons in my journal as follows:

Server Error in '/' Application.
Object reference not set to an instance of an object.

Unfortunately, not having had debug mode active on the page at the time I wasn't able to get more details on the error cause (and as I said I haven't been able to replicate it).

The navigation buttons on my page are simple and the code is as follows:

protected void newestButton_Click(object sender, EventArgs e)
    {
        Response.Redirect("blogged.aspx?post=" + highestPost.ToString());
    }
    protected void oldestButton_Click(object sender, EventArgs e)
    {
        Response.Redirect("blogged.aspx?post=" + lowestPost.ToString());
    }
    protected void fwdButton_Click(object sender, EventArgs e)
    {
        Response.Redirect("blogged.aspx?post=" + nextPost.ToString());
    }
    protected void backButton_Click(object sender, EventArgs e)
    {
        Response.Redirect("blogged.aspx?post=" + prevPost.ToString());
    }

The post ranges used are generated by:

private void navButtonSetup()
    {
        //initialize navigation button visibility
        string connStr = @loadConn.cString;
        SqlConnection loadMsgConn = new SqlConnection(@connStr);
        SqlDataAdapter loadMsgAdapt = new SqlDataAdapter(@"SELECT mID FROM blMessages WHERE isDeleted = 'False'", loadMsgConn);
        SqlCommandBuilder loadMsgBuilder = new SqlCommandBuilder(loadMsgAdapt);
        DataSet loadMsgSet = new DataSet();
        loadMsgAdapt.Fill(loadMsgSet, "origMsg");
        loadMsgConn.Close();
        if (loadMsgSet.Tables["origMsg"].Rows.Count > 0) //Determine if table contains more than 0 listings
        {
            for (int i = 0; i < loadMsgSet.Tables["origMsg"].Rows.Count; i++) //cycle through list of replies to determine lowest/highest reply IDs and list all of them
            {
                DataRow respRow = loadMsgSet.Tables["origMsg"].Rows[i];
                string resID = respRow["mID"].ToString();
                msgIDList += resID.ToString();
                if (i < loadMsgSet.Tables["origMsg"].Rows.Count - 1)
                {
                    msgIDList += ",";
                }
            }
        }
        string[] listedString = msgIDList.Split(','); //split list into component parts
        int[] listedIDs = new int[listedString.Length];
        for (int i = 0; i < listedString.Length; i++)
        {
            listedIDs[i] = Convert.ToInt16(listedString[i]);
        }
        lowestPost = listedIDs[0]; //determine lowest replyID in list
        highestPost = listedIDs[listedIDs.Length - 1]; //determine highest replyID in list
        for (int a = 0; a < listedIDs.Length; a++) //cycle through list to determine "next" and "previous" replyIDs for navigation
        {
            if (listedIDs[a] == origNum)
            {
                if (a - 1 >= 0)
                {
                    prevPost = listedIDs[a - 1];
                }
                else
                {
                    prevPost = listedIDs[a];
                }
                if (a + 1 <= listedIDs.Length - 1)
                {
                    nextPost = listedIDs[a + 1];
                }
                else
                {
                    nextPost = listedIDs[a];
                }
            }
        }

I've included a zip of the .aspx and .aspx.cs files relevant to this scenario as I don't think anyone wants me to post the entire code here and it's possible that the error is generated by another segment other than just the navigation buttons.

As I said, if I could replicate it I'd have more information for you but unfortunately you now have as much info as I do and I'm hoping someone might be able to help figure this out :)

2
Contributors
6
Replies
7
Views
7 Years
Discussion Span
Last Post by Lusiphur
1

Object reference not set to an instance of an object.

That usually refers to No Data being retrieved from The DB.

There are no such entries in the DB.

Since you know your code best, you should look to all the places where you are trying to Retrieve data, or think where this may be.

So in your case

SqlDataAdapter loadMsgAdapt = new SqlDataAdapter(@"SELECT mID FROM blMessages WHERE isDeleted = 'False'", loadMsgConn);

has to be the culprit.

Try adding a Try{} Catch{}

On second thought:

Code looks fine, I think this may be a timeout issue.

Edited by finito: n/a

Votes + Comments
Bump for reading all that code! :)
0

Code looks fine, I think this may be a timeout issue.

See that's what I'm thinking because the code excecutes flawlessly every attempt I make at replicating the error, and only certain people seem to be getting errors.

Any thoughts on what would be causing a timeout issue however? Or would I be safe in my initial assumption that it may be related to my host and the fact that I get to share bandwidth/resources/etc with everyone else on the same shared hosting node as me?

0

That depends, not all shared hosting service operate the same way, but it is very plausible.

My knowledge on the Subject is limited, but I would suggest you add a timeout clause.

0

As much as I'd love to do that (and I did try to look it up for anyone who's wondering) I'm not entirely sure how to go about it.

It actually seems possibly related to http://msdn.microsoft.com/en-us/library/ms972429.aspx and I bring that into the equation only because an error that I have come across once or twice has occurred if I left my journal page open while I went over here to DaniWeb to answer a question or two and go back I get a session error (which is solved by reloading the page but still).

I somewhat wonder if the two are inter-related.

0

I think that would more likely be a different error, but as I said my knowledge on this matter is limited, I am sure someone else on the forum knows and will provide an answer.

0

Anyone else have any thoughts on this before I mark it solved as a matter of housekeeping?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.