mrpddnos
Member
For a school assignment I have to write a small program that allows the user to safe a student number and status (present(1) or absent(0)) into a data set.
I wrote the code but when I start the project in debug mode I get an error when I try to add a new student to the dataset. I don;t know the exact error as my Visual Studio is the Dutch version. Its something about an object reference with has no object to refere to?
Below you kan see the code. I hope you can help me!
Dataset and Datatable
The code in question
I wrote the code but when I start the project in debug mode I get an error when I try to add a new student to the dataset. I don;t know the exact error as my Visual Studio is the Dutch version. Its something about an object reference with has no object to refere to?
Below you kan see the code. I hope you can help me!
Dataset and Datatable
Code:
DataSet dsStudenten = new DataSet("studenten");
DataTable dtStudent = new DataTable("student");
The code in question
Code:
private void BtnAanmelden_Click(object sender, EventArgs e)
{
DataRow drStudent = dsStudenten.Tables["student"].NewRow();
if (cbAanw.Checked)
{
instatus = "1";
}
else
{
instatus = "0";
}
drStudent["ovnummer"] = TbOvnr.Text;
drStudent["instatus"] = instatus;
dsStudenten.Tables["student"].Rows.Add(drStudent);
LbStudenten.Items.Add(drStudent[0]);
TbOvnr.Clear();
}