in

System.Data.SQLite

An open source ADO.NET provider for the SQLite database engine

C#, .NET CF 2.0 - The changes are not saved on database.

Last post 06-05-2008 9:57 AM by acidbytes. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 06-04-2008 12:24 PM

    • acidbytes
    • Top 500 Contributor
    • Joined on 06-04-2008
    • São Paulo - Brazil
    • Posts 3

    C#, .NET CF 2.0 - The changes are not saved on database.

     The scenario:

        Application developed with Visual Studio 2005, C#, .NET CF 2.0, SQLite, Windows CE 5.

       The problem.

       The user search for a register in database, runs OK, the user change a information in the register and save it.

       The user make a new search for that register, and the new information is ok.

       The user exits the application, and return to application again, and consult that register, and the changes are not in register, he lost their changes. 

     

      The code:

      a class that manage the connection:

       {
        class Conexao
            {
            private static SQLiteConnection con = new SQLiteConnection("data source=\\Storace Card\\ESACSWinCE.db;New=False");
            private Conexao(){}
            public static SQLiteConnection getConexao()
                {
                    return con;
                }
            }
        } 

     

    the only place where have a Update statement in the code:

                public string SaveIt(bool NewItem)
                    {
                      string strSQL = "";
                      string result_str = "";
                      bool error_save = false;
     

                     SQLiteCommand cmd = (Conexao.getConexao()).CreateCommand();
     

                       strSQL = "UPDATE ITENS SET .... "; // The SQL statement for make update.

                       }
                     if (!error_save)
                        {
                          cmd.CommandText = strSQL;
                          try
                              {
                               cmd.ExecuteNonQuery();

                              }

                          catch (Exception E)
                              {
                                result_str = "(" + E.ToString() + ")" + E.Message;
                              }

          The application allways save the journal file, I can see it on HandHeld, but the changes are not update in the real database.

         I try using transactions too, but nothing, continues with the same error.

     

         Anyone can help me??? 


                     

  • 06-04-2008 4:50 PM In reply to

    Re: C#, .NET CF 2.0 - The changes are not saved on database.

     It really sounds to me like you're not properly committing the data.  If you're seeing the journal file there, that leads me to believe that you've got a dangling transaction.  I highly suspect that your problem is the class to manage the connection is never disposing or comitting the transactions.  

  • 06-05-2008 8:21 AM In reply to

    • acidbytes
    • Top 500 Contributor
    • Joined on 06-04-2008
    • São Paulo - Brazil
    • Posts 3

    Re: C#, .NET CF 2.0 - The changes are not saved on database.

     Hi Jeffrey, tks for your answer,

     

               I suspect that are a problem with my connection object, it's my first application writen with SQLite, when the user choose close the application, I fire this event:

                   Conexao.getConexao().Close();
                   Conexao.getConexao().Dispose();
                   Application.Exit();

     

               But nothing occur, I see a journaling file in the directory, and the changes are not commited in the database.

     

            
     


  • 06-05-2008 9:57 AM In reply to

    • acidbytes
    • Top 500 Contributor
    • Joined on 06-04-2008
    • São Paulo - Brazil
    • Posts 3

    Re: C#, .NET CF 2.0 - The changes are not saved on database.

     Hi again.

               I find the solution, the problem is that when I run the application in WinCE 5.0 emulator, the problem exists and the data never is commited in the database, if I send the application to real device via ActiveSync, the problem not occur, in the real handheld the data is saved OK in the database.

               I suspect that's a problem with emulator in Windows Vista, when I test it on Windows XP SP2, it runs OK, and in the handheld its run OK too.

     

               Tks for all.
     

              
     

            

Page 1 of 1 (4 items)
Powered by Community Server (Commercial Edition), by Telligent Systems