Beispiel #1
0
        public bool copyCreationTable(MysqlHandler connection, string sourceTable, MysqlHandler targetConnection)
        {
            bool disconnecting       = false;
            bool targetDisconnecting = false;

            if (!connection.isConnected())
            {
                disconnecting = true;
                connection.connect();
            }

            if (!targetConnection.isConnected())
            {
                targetDisconnecting = true;
                targetConnection.connect();
            }
            string createSql = connection.getTableCreationString(sourceTable);

            if (createSql != "")
            {
                targetConnection.sql_update(createSql);
            }
            if (disconnecting)
            {
                connection.disConnect();
            }
            if (targetDisconnecting)
            {
                targetConnection.disConnect();
            }

            targetConnection.resetTableList();
            return(targetConnection.tableExists(sourceTable));
        }
Beispiel #2
0
        public void copyTable(MysqlHandler connection, string sourceTable, MysqlHandler targetConnection)
        {
            bool disconnecting       = false;
            bool targetDisconnecting = false;

            if (!connection.isConnected())
            {
                disconnecting = true;
                connection.connect();
            }

            if (!targetConnection.isConnected())
            {
                targetDisconnecting = true;
                targetConnection.connect();
            }

            targetConnection.lastSqlErrorMessage = "";

            if (!targetConnection.tableExists(sourceTable))
            {
                string createSql = connection.getTableCreationString(sourceTable);
                targetConnection.sql_update(createSql);
                if (targetConnection.lastSqlErrorMessage.Length > 0)
                {
                    MessageBox.Show(createSql + "\n\n" + targetConnection.lastSqlErrorMessage);
                    targetConnection.lastSqlErrorMessage = "";
                }
                else
                {
                    copyRows(connection, sourceTable, targetConnection);
                }
            }



            if (disconnecting)
            {
                connection.disConnect();
            }
            if (targetDisconnecting)
            {
                targetConnection.disConnect();
            }

            targetConnection.resetTableList();
        }
Beispiel #3
0
        public String alterTableFromSource(MysqlHandler connection, string sourceTable, MysqlHandler targetConnection, Boolean addOnly)
        {
            bool disconnecting       = false;
            bool targetDisconnecting = false;

            if (!connection.isConnected())
            {
                disconnecting = true;
                connection.connect();
            }

            if (!targetConnection.isConnected())
            {
                targetDisconnecting = true;
                targetConnection.connect();
            }
            string             createSql    = connection.getTableCreationString(sourceTable);
            List <MysqlStruct> sourceStruct = connection.getAllFieldsStruct(sourceTable);
            List <MysqlStruct> targetStruct = targetConnection.getAllFieldsStruct(sourceTable);

            String alterSql = getAlterTableSql(sourceStruct, targetStruct, addOnly);

            if (alterSql.Length > 0)
            {
                alterSql = "ALTER TABLE `" + sourceTable + "` " + alterSql;
            }
            if (disconnecting)
            {
                connection.disConnect();
            }
            if (targetDisconnecting)
            {
                targetConnection.disConnect();
            }

            targetConnection.resetTableList();
            return(alterSql);
        }