Additional information: Object reference not set to an instance of an object.
I have this code
DotTeachDataSet ds;
DotTeachDataSetTableAdapters.QuestionsTableAdapter ta;
private void button1_Click(object sender, RoutedEventArgs e)
{
ta.CreateQuestion(discussionQuestion.Text, webPage.Text, choiceA.Text, choiceB.Text, choiceC.Text, choiceD.Text, hint.Text, rightAnswerCbox.Uid);
ta.Fill(ds.Questions);
}
That Im using to try to get the values from text boxes in a xaml and send them to a data base but I keep getting the error:
An unhandled exception of type
‘System.NullReferenceException’
occurred in DotTeach.exeAdditional information: Object
reference not set to an instance of an
object.
and visual studio highlights the line
ta.CreateQuestion(discussionQuestion.Text, webPage.Text, choiceA.Text, choiceB.Text, choiceC.Text, choiceD.Text, hint.Text, rightAnswerCbox.Uid);
Does anyone have any ideas what i could try?
I got rid of the error message but it’s still not doing what I need it to do. I’m trying to get it to add data to a database when the button is clicked. Heres the function I’m using thats not working
private void button1_Click(object sender, RoutedEventArgs e)
{
DotTeach.DotTeachDataSet dotTeachDataSet = ((DotTeach.DotTeachDataSet)(this.FindResource("dotTeachDataSet")));
DotTeach.DotTeachDataSetTableAdapters.QuestionsTableAdapter dotTeachDataSetQuestionsTableAdapter = new DotTeach.DotTeachDataSetTableAdapters.QuestionsTableAdapter();
//ADD THE QUESTION TO THE DATA BASE
dotTeachDataSetQuestionsTableAdapter.CreateQuestion(discussionQuestion.Text, webPage.Text, choiceA.Text, choiceB.Text, choiceC.Text, choiceD.Text, hint.Text, rightAnswer.Text);
}
I’m not even sure what else to try.
Well, to get a
NullReferenceException, one of the following is null:My guess would be
ta, but you should be able to find that out either with logging or in the debugger. What’s meant to be assigning a non-null value tota?Is this always failing (in which case it’ll be easy to diagnose) or only sometimes?