I have a DataSet called DataHolder, that holdes several tables. The DataHolder class is a UserControl, that also holds the connection to the database.
When the Dataholder starts it fills in different SqlDataAdapters with commands used for selects, deletes and updates of different tables.
Here is the problem, one of the tables has no inserts and therefore I use this code.
That code does not work the statement this.dataHolder.GetChanges(DataRowState.Modified) goes through the Constructor of DataHolder.
If I do like this the code works ok
Do anyone know why?
Thanks in advance.
When the Dataholder starts it fills in different SqlDataAdapters with commands used for selects, deletes and updates of different tables.
Here is the problem, one of the tables has no inserts and therefore I use this code.
Code:
if (this.dataHolder.HasChanges(DataRowState.Modified)) {
DataSet tempDS = this.dataHolder.GetChanges (DataRowState.Modified);
if tempDS.Tables.ContainsDataHolder.TableNameProdDataPre)){ this.dataHolder.SqlPreviewDataAdapter.Update (tempDS, DataHolder.TableNameProdDataPre);
this.dataHolder.AcceptChanges();
}
}
That code does not work the statement this.dataHolder.GetChanges(DataRowState.Modified) goes through the Constructor of DataHolder.
If I do like this the code works ok
Code:
if (this.dataHolder.HasChanges(DataRowState.Modified)) {
DataSet tempDS = this.dataHolder.GetChanges();
if (tempDS.Tables.Contains(DataHolder.TableNameProdDataPre)) {
this.dataHolder.SqlPreviewDataAdapter.Update(tempDS, DataHolder.TableNameProdDataPre);
this.dataHolder.AcceptChanges();
}
}
Do anyone know why?
Thanks in advance.