private void copyTable()
            {
                dropDestinationTable();

                using (var cmd = _destination.CreateCommand())
                {
                    cmd.CommandText = _destinationTable;
                    cmd.CommandType = CommandType.TableDirect;

                    _operation.StatusDescription       = "Services_Definitions_CreatingDestTable";
                    _operation.IsProgressIndeterminate = true;

                    IDbCommand readCmd = _source.CreateCommand();
                    readCmd.CommandText = "SELECT * FROM " + _sourceExpression;
                    DataTable schema = null;
                    using (var sourceReader = readCmd.ExecuteReader())
                    {
                        schema = sourceReader.GetSchemaTable();
                        sourceReader.Close();
                    }

                    createDestinationTable(schema);

                    int rowCount = countRowsToCopy();

                    using (var sourceReader = readCmd.ExecuteReader())
                    {
                        _operation.StatusDescription       = "Services_Definitions_LoadingTaxa";
                        _operation.IsProgressIndeterminate = false;


                        var copyOperation = new ProgressInterval(_operation, _progressPerTaxonList, rowCount);

                        using (var destinationResultSet = cmd.ExecuteResultSet(ResultSetOptions.Updatable | ResultSetOptions.Scrollable))
                        {
                            while (sourceReader.Read())
                            {
                                SqlCeUpdatableRecord record = destinationResultSet.CreateRecord();
                                object[]             values = new object[sourceReader.FieldCount];
                                sourceReader.GetValues(values);
                                record.SetValues(values);
                                destinationResultSet.Insert(record);
                                copyOperation.advance();
                            }
                            destinationResultSet.Close();
                        }
                        sourceReader.Close();
                    }
                }
                return;
            }
示例#2
0
        private void copyDBExpressionToTable()
        {
            dropDestinationTable();

            using (var cmd = destination.CreateCommand())
            {
                cmd.CommandText = destinationTable;
                cmd.CommandType = CommandType.TableDirect;


                int rowCount = countRowsToCopy();


                IDbCommand readCmd = source.CreateCommand();
                readCmd.CommandText = "SELECT * FROM " + sourceExpression;
                using (var sourceReader = readCmd.ExecuteReader())
                {
                    createDestinationTable(sourceReader.GetSchemaTable());

                    var internalProgress = progress.startInternal(progressPerTaxonList, rowCount);

                    using (var destinationResultSet = cmd.ExecuteResultSet(ResultSetOptions.Updatable | ResultSetOptions.Scrollable))
                    {
                        while (sourceReader.Read())
                        {
                            SqlCeUpdatableRecord record = destinationResultSet.CreateRecord();
                            object[]             values = new object[sourceReader.FieldCount];
                            sourceReader.GetValues(values);
                            record.SetValues(values);
                            destinationResultSet.Insert(record);

                            internalProgress.advance();
                        }
                    }
                    sourceReader.Close();
                }
            }
            return;
        }