C
Christopher Weaver
I'm confused about the relationships between these objects. I've written
this:
DataSet dsTaskActivities = new DataSet("TA");
DataTable dtTask = dsTaskActivities.Tables.Add("Tasks");
DataTable dtActivity = dsTaskActivities.Tables.Add("Activity");
OdbcCommand cmd = new OdbcCommand();
cmd.Connection = odbcIB;
cmd.CommandText = "SELECT * FROM \"tblTasks\"";
odbcDA_TaskActivities.SelectCommand = cmd;
odbcDA_TaskActivities.Fill(dsTaskActivities, "Tasks");
cmd.CommandText = "SELECT * FROM \"tblActivity\"";
odbcDA_TaskActivities.SelectCommand = cmd;
odbcDA_TaskActivities.Fill(dsTaskActivities, "Activity");
It compiles fine but crashes on the last line with this message:
An unhandled exception of type 'System.NullReferenceException' occurred in
system.data.dll
Additional information: Object reference not set to an instance of an
object.
What's really confusing is why it will run through
odbcDA_TaskActivities.Fill(dsTaskActivities, "Tasks");
without complaint but crash on
odbcDA_TaskActivities.Fill(dsTaskActivities, "Activity");
I've read the Help text on these subjects and patterned this code after one
of the examples. Clearly I'm missing some fundamental information about how
these objects relate to one another. Would anyone like to lend some
elucidation?
this:
DataSet dsTaskActivities = new DataSet("TA");
DataTable dtTask = dsTaskActivities.Tables.Add("Tasks");
DataTable dtActivity = dsTaskActivities.Tables.Add("Activity");
OdbcCommand cmd = new OdbcCommand();
cmd.Connection = odbcIB;
cmd.CommandText = "SELECT * FROM \"tblTasks\"";
odbcDA_TaskActivities.SelectCommand = cmd;
odbcDA_TaskActivities.Fill(dsTaskActivities, "Tasks");
cmd.CommandText = "SELECT * FROM \"tblActivity\"";
odbcDA_TaskActivities.SelectCommand = cmd;
odbcDA_TaskActivities.Fill(dsTaskActivities, "Activity");
It compiles fine but crashes on the last line with this message:
An unhandled exception of type 'System.NullReferenceException' occurred in
system.data.dll
Additional information: Object reference not set to an instance of an
object.
What's really confusing is why it will run through
odbcDA_TaskActivities.Fill(dsTaskActivities, "Tasks");
without complaint but crash on
odbcDA_TaskActivities.Fill(dsTaskActivities, "Activity");
I've read the Help text on these subjects and patterned this code after one
of the examples. Clearly I'm missing some fundamental information about how
these objects relate to one another. Would anyone like to lend some
elucidation?