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

How to post json array to PHP using jQuery's ajax method?

javascript php jquery ajax json

I have a json array created by javascript and need to post it to a php file in order to save the data into the database.

css margin:auto not centering div in webkit browsers (Chrome and Safari) when maximised/full screen

html css webkit overflow margin

I have been unable to determine the cause of this problem, so I can not display a test case,

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.