Exemplo n.º 1
0
    /* OLD STUFF */

    /*
     * don't do more like this, use Sqlite.convertTables()
     */
    //change DB from 0.55 to 0.56
    protected internal static void convertTableAddingSportStuff()
    {
        ArrayList myArray = new ArrayList(2);

        //1st create a temp table
        //createTable(Constants.ConvertTempTable);
        SqliteSessionOld sqliteSessionObject = new SqliteSessionOld();

        sqliteSessionObject.createTable(Constants.ConvertTempTable);

        //2nd copy all data from session table to temp table
        dbcmd.CommandText = "SELECT * " +
                            "FROM " + Constants.SessionTable + " ORDER BY uniqueID";
        SqliteDataReader reader;

        reader = dbcmd.ExecuteReader();
        while (reader.Read())
        {
            Session mySession = new Session(reader[0].ToString(), reader[1].ToString(),
                                            reader[2].ToString(), UtilDate.FromSql(reader[3].ToString()),
                                            1,                    //sport undefined
                                            -1,                   //speciallity undefined
                                            -1,                   //practice level undefined
                                            reader[4].ToString(), //comments
                                            Constants.ServerUndefinedID
                                            );
            myArray.Add(mySession);
        }
        reader.Close();

        foreach (Session mySession in myArray)
        {
            InsertOld(true, Constants.ConvertTempTable,
                      mySession.Name, mySession.Place, UtilDate.ToSql(mySession.Date),
                      mySession.PersonsSportID, mySession.PersonsSpeciallityID, mySession.PersonsPractice, mySession.Comments);
        }

        //3rd drop table sessions
        Sqlite.dropTable(Constants.SessionTable);

        //4d create table persons (now with sport related stuff
        //createTable(Constants.SessionTable);
        sqliteSessionObject.createTable(Constants.SessionTable);

        //5th insert data in sessions (with sport related stuff)
        foreach (Session mySession in myArray)
        {
            InsertOld(true, Constants.SessionTable,
                      mySession.Name, mySession.Place, UtilDate.ToSql(mySession.Date),
                      mySession.PersonsSportID, mySession.PersonsSpeciallityID, mySession.PersonsPractice, mySession.Comments);
        }


        //6th drop temp table
        Sqlite.dropTable(Constants.ConvertTempTable);
    }
Exemplo n.º 2
0
    /* OLD STUFF */
    /*
     * don't do more like this, use Sqlite.convertTables()
     */
    //change DB from 0.55 to 0.56
    protected internal static void convertTableAddingSportStuff()
    {
        ArrayList myArray = new ArrayList(2);

        //1st create a temp table
        //createTable(Constants.ConvertTempTable);
        SqliteSessionOld sqliteSessionObject = new SqliteSessionOld();
        sqliteSessionObject.createTable(Constants.ConvertTempTable);

        //2nd copy all data from session table to temp table
        dbcmd.CommandText = "SELECT * " +
            "FROM " + Constants.SessionTable + " ORDER BY uniqueID";
        SqliteDataReader reader;
        reader = dbcmd.ExecuteReader();
        while(reader.Read()) {
            Session mySession = new Session(reader[0].ToString(), reader[1].ToString(),
                    reader[2].ToString(), UtilDate.FromSql(reader[3].ToString()),
                    1, //sport undefined
                    -1, //speciallity undefined
                    -1, //practice level undefined
                    reader[4].ToString(), //comments
                    Constants.ServerUndefinedID
                    );
            myArray.Add(mySession);
        }
        reader.Close();

        foreach (Session mySession in myArray)
            InsertOld(true, Constants.ConvertTempTable,
                mySession.Name, mySession.Place, UtilDate.ToSql(mySession.Date),
                mySession.PersonsSportID, mySession.PersonsSpeciallityID, mySession.PersonsPractice, mySession.Comments);

        //3rd drop table sessions
        Sqlite.dropTable(Constants.SessionTable);

        //4d create table persons (now with sport related stuff
        //createTable(Constants.SessionTable);
        sqliteSessionObject.createTable(Constants.SessionTable);

        //5th insert data in sessions (with sport related stuff)
        foreach (Session mySession in myArray)
            InsertOld(true, Constants.SessionTable,
                mySession.Name, mySession.Place, UtilDate.ToSql(mySession.Date),
                mySession.PersonsSportID, mySession.PersonsSpeciallityID, mySession.PersonsPractice, mySession.Comments);

        //6th drop temp table
        Sqlite.dropTable(Constants.ConvertTempTable);
    }