Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 964423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:49:28+00:00 2026-05-16T01:49:28+00:00

Sorry about the title, I don’t think I could explain it right: This is

  • 0

Sorry about the title, I don’t think I could explain it right:

This is a simplified example class, this is working ok. (I also have a Save() method)

   public class busItem
    {

        public Item vItem;

        public busItem(int pItem_Id)
        {
            DBDataContext db = new DBDataContext();

            Item vItemQuery = (from i in db.Items
                               where i.Id == pItem_Id
                               select i).FirstOrDefault();

            vItem = new Item();

            vItem.Id = vItemQuery.Id;
            vItem.Desc = vItemQuery.Desc;

        }
    }

And this is my code-behind call:

busItem item = new busItem(1);
item.vItem.Desc = "new description";

the problem is that when I try passing the “new description”, i get a “null reference” exception. How can I do that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T01:49:29+00:00Added an answer on May 16, 2026 at 1:49 am

    First of all, that code doesn’t look right for at least 2 reasons. pItem in the query is not declared; did you mean pItem_Id? Also, the line with “new description” doesn’t end with a semicolon. Unless I’m looking at the exact code you have, there’s a good chance the actual problem win’t be visible. Secondly, I suspect the error is not actually when you assign “new description” but when you assign vItem.Desc = vItemQuery.Desc. I don’t see how the “new description” line could be a problem, but if the query returned null because it couldn’t find the requested object, you’d get an error when trying to get the original/default description.

    Edit: Are you sure you didn’t exclude some significant piece of code like declaring a local instance of vItem within the constructor?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry about the title, don't know how to phrase this. I have my own
Sorry about the vague title, but I really don't know how to describe this
Sorry about the title, I couldn't think of a better way to describe the
Sorry about the title, but I don't know how to say what I want.
Sorry about the weird question title, but I don't really know what to call
sorry about the title, I'm not sure how to even describe this, which makes
Sorry about the title, not sure how to describe without example. I trying to
Sorry about the title, couldn't really think of anything else to describe the problem
I'm sorry about the title I'm just not sure how to describe this one.
First, I'm sorry about the title, that was the best I could come up

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.