C
Christopher Weaver
I'm trying to insert a new Row within an existing Table within an existing
DataSet using the following:
DataRow NewTaskRow = dsTaskActivities.Tables["Tasks"].NewRow();
dsTaskActivities.Tables["Tasks"].Rows.Add(NewTaskRow);
I'm using the code from the help text to remove the constraints within
dsTaskActivities before executing the Add
public static void ClearConstraints(DataSet ds)
{
foreach (DataTable t in ds.Tables)
t.Constraints.Clear();
}
However, I receive this error message:
Remove foreign key constraint 'TaskActivities' first.
'TaskActivities' is the name of a Relation in dsTaskActivities that defines
the master / detail relationship between the two Tables within the
dsTaskActivities . So I inserted this before the call to ClearConstraints:
dsTaskActivities.Relations.Remove("TaskActivities");
This additional line of code did not raise an exception, but it didn't
remove the foreignkey constraint either. I'm still receiving the same error
message.
Is there another way to go about this? I'm simply trying to insert a new
record in the DataSet on the master table side. I'm not including a value
in the unique ID field because it is added automatically by the server.
Any suggestions will be greatly appreciated.
DataSet using the following:
DataRow NewTaskRow = dsTaskActivities.Tables["Tasks"].NewRow();
dsTaskActivities.Tables["Tasks"].Rows.Add(NewTaskRow);
I'm using the code from the help text to remove the constraints within
dsTaskActivities before executing the Add
public static void ClearConstraints(DataSet ds)
{
foreach (DataTable t in ds.Tables)
t.Constraints.Clear();
}
However, I receive this error message:
Remove foreign key constraint 'TaskActivities' first.
'TaskActivities' is the name of a Relation in dsTaskActivities that defines
the master / detail relationship between the two Tables within the
dsTaskActivities . So I inserted this before the call to ClearConstraints:
dsTaskActivities.Relations.Remove("TaskActivities");
This additional line of code did not raise an exception, but it didn't
remove the foreignkey constraint either. I'm still receiving the same error
message.
Is there another way to go about this? I'm simply trying to insert a new
record in the DataSet on the master table side. I'm not including a value
in the unique ID field because it is added automatically by the server.
Any suggestions will be greatly appreciated.