0

What could be wrong ?

public int InsertUpdateQues(bllQues objbllQues)
    {


        dsgetQues = objdllQues.InsertUpdateQues(this);  //ERROR here
        return dsgetQues;
    }

I see values getting assigned to ALL the above properties, not one is missing. Whats wrong then?

EDIT I found the error..In my dllQue class's insert update method I had two entries as sqlParam[4] =new... and sqlParam[4] =new...chnaged the 2nd one to 5.. damn..the problem is I KEEP on making silly mistakes! :( How can I avoid this so my time is not wasted this way ???

4
  • Show us the code for InsertUpdateQues(this). Object reference can be spotted easily by finding which object has gone null. Commented Dec 4, 2010 at 6:01
  • It is very easy to get confused between objdllQues and objbllQues. Could you please change the names of the variables? It will be easier for people reading the code. Commented Dec 4, 2010 at 6:02
  • I agree with @Unmesh. Hungarian notation is not recommended in C# development and your variable names are so similar it could easily lead to confusion. Commented Dec 4, 2010 at 6:11
  • This code is fairly confusing with the copying of properties, creating of a dependency, assigning to the current object with this, and then passing it to a method. Consider extracting the properties on the BLL into a DTO at least and pass that around. A better scenario is create a model instance and use the repository pattern with an ORM. Commented Dec 4, 2010 at 6:21

1 Answer 1

1

It might help to use constants for your indexes so that your code would look something like sqlParam[CustomerName] = ... That would help readability a little and you might catch your mistakes faster.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.