Search code examples
c#datasetsql-server-ce

TableAdapter.Update() doesn't work


I want to remove existing records from Database and add new data to Database. I used the following code. It is running correctly but when I see database through database viewer in Visual Studio, I can't see any update in Database.

Databases.MoodleOCDataSet quizDT = new Databases.MoodleOCDataSet();
Databases.MoodleOCDataSetTableAdapters.QuizTableAdapter tableAdaptor = new Databases.MoodleOCDataSetTableAdapters.QuizTableAdapter();            
tableAdaptor.Fill(new Databases.MoodleOCDataSet.QuizDataTable());

string[] quizList = GetServerQuizList();

quizDT.Quiz.Clear();

foreach(string quiz in quizList)
{
    Databases.MoodleOCDataSet.QuizRow row = quizDT.Quiz.NewQuizRow();
    row.course = 1;
    row.name = quiz;
    quizDT.Quiz.Rows.Add(row);
}

tableAdaptor.Update(quizDT.Quiz); 

Solution

  • Actually this is not a issue with update command. Visual Studio keeps two databases. One in project folder and one in bin/debug folder. Database in bin/debug folder always update with Database in project folder. If you view Database through Visual Studio, it always shows the Database inside the project folder not other one inside bin/debug folder.