5
Answers

Object reference not set to an instance of an object.

Anna Hawks

Anna Hawks

16y
2.6k
1

I'm sure I'm just tired and will feel really stupid when I find out the answer, but I have a Web Page that when it tries to set Insert Parameters gives me a NullReferenceException (see subject)

The specific method is :

protected void frmChgRequest_Inserting(object sender, FormViewInsertEventArgs e) {

SqlChgRequest.InsertParameters["ChgID"].DefaultValue = chgIDComplete.ToString();

SqlChgRequest.InsertParameters["RequestDate"].DefaultValue = DateTime.Now.ToString();

}

The error occurs on the first InsertParameters statement. The obvious answer is that the stringbuilder "chgIDComplete" is null, but on debug, it shows a value of "MERCHANT2008115HW". A stringbuilder should have no problem converting to a string. What am I doing wrong?

Answers (5)