C# Table Adapter Update Not Working

I am trying to serialize an object to a sql compact database. I am using VCS Express 2008. Every time I run a test to see if my data is sent to the database, nothing is in the database. My code:

string inputForDB = null;
                QuizCategoryTableAdapter quizCategoryAdapter = new QuizCategoryTableAdapter();
                QuizApp._QuizApp_DataSet.QuizCategoryDataTable quizCategoryTable = new QuizApp._QuizApp_DataSet.QuizCategoryDataTable();
                quizCategoryAdapter.Fill(quizCategoryTable);
                //Check to see if quizCategory exists
                if (quizCategoryTable.Rows.Contains(quizCategory._categoryID)) {
                    //overwrite (update)
                    //Serialize the object and put in db
                    MemoryStream MemStream = new MemoryStream();
                    IFormatter formatter = new BinaryFormatter();
                    formatter.Serialize(MemStream, quizCategory);
                    inputForDB = Convert.ToBase64String(MemStream.ToArray());
                    quizCategoryAdapter.Insert(quizCategory._categoryName, quizCategory._categoryDescription, inputForDB);
                    //send update to database
                    MemStream.Close();
                } else {
                    //append (insert)
                    MemoryStream MemStream2 = new MemoryStream();
                    IFormatter formatter2 = new BinaryFormatter();
                    formatter2.Serialize(MemStream2, quizCategory);
                    inputForDB = Convert.ToBase64String(MemStream2.ToArray());
                    quizCategoryAdapter.Insert(quizCategory._categoryName, quizCategory._categoryDescription, inputForDB);
                    MemStream2.Close();
                }

It compiles fine, but for some reason does not work.

Answers


You have to call the Adapter Update method as well as AcceptChanges on the DataSet


Need Your Help

requirejs circular dependencies and function objects

javascript requirejs classloader circular-dependency

Is it possible to differentiate between dependencies which are needed on structure build (like inheritance) and runtime dependencies (within a method call).