dataset.ApplyChanges() not taking effect.

  • Thread starter Thread starter greatbarrier86
  • Start date Start date
G

greatbarrier86

Here is my code.

Does anyone know why when i reopen the table to view the data, none of the
rows have been written?

DownloadFileDataSet.DownloadFileRow MainTableRow =
(DownloadFileDataSet.DownloadFileRow)downloadFileDataSet.DownloadFile.NewRow();
MainTableRow.Date = DateTime.Now;
MainTableRow.RowID = gDownloadFileTableGUID;
MainTableRow.FileName = sFileName;
MainTableRow.URL = sSource;
MainTableRow.FileSize = iFileLength.ToString();
downloadFileDataSet.DownloadFile.AddDownloadFileRow(MainTableRow);

//Save the dataset to the database
downloadFileDataSet.AcceptChanges();
 
            //Save the dataset to the database
            downloadFileDataSet.AcceptChanges();

IIRC AcceptChanges do not save the changes to the DB, only to the
dataset in memory
 
How do i save the changes to the DB?

Ignacio Machin ( .NET/ C# MVP ) said:
IIRC AcceptChanges do not save the changes to the DB, only to the
dataset in memory
 
How do i save the changes to the DB?

I had exactly the same problem ended up with:

internal void UpdateDatabase()
{
EndEditOnAllBindingSources();

tableAdapterManager.UpdateAll(scoreDataset);

}


private void EndEditOnAllBindingSources()
{
var BindingSourcesQuery =
from Component bindingSources in
this.components.Components
where bindingSources is BindingSource
select bindingSources;

foreach (BindingSource bindingSource in BindingSourcesQuery)
{
bindingSource.EndEdit();
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top