Reputation: 75
Why does this code work..
DataTable dt = new DataTable();
dt = sitesformdataset.Tables[MainTableStringName].DefaultView.ToTable();
When this code does not...
sitesformdataset.Tables[MainTableStringName] = sitesformdataset.Tables[MainTableStringName].DefaultView.ToTable();
It says "Property or indexer 'System.Data.DataTableCollection.this[string]' cannot be assigned to -- it is read only"
Upvotes: 0
Views: 4307
Reputation: 460068
The error is self-explanatory. Because you try to assign a table to the Tables
indexer of the DataSet
which is readonly.
public DataTable this[
string name
] { get; } // <-- readonly
Upvotes: 2