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 this long block of code, but I think it makes sense to
Sorry about the title. I do realize it's not very descriptive. :| Here is
Well, sorry about the confusing title but I'm having a slightly annoying problem with
Sorry if the title is not very clear. I was not sure about the
Okay the question title may not have made sense... mostly because I don't know
Think the title describes my thoughts pretty well :) I've seen a lot of
just exploring c# 4. Trying to get my head around all this dynamic stuff.
Are Java style camelCase names good practice in Python. I know Capilized names should
I've written two python scripts script1.py and script2.py. I want to run script1.py from
First, the setup: I have a table in an Oracle10g database with spatial columns.

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.