Esempio n. 1
0
        /// <summary>
        /// Error handler if the returned data cannot be converted by .NET from SQL.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        protected override sealed void FillError(object sender, FillErrorEventArgs args)
        {
            // Code to handle precision loss.
            object errorSOQty     = 0.0m;
            object errorSalePrice = 0.0m;
            object errorShipDate  = DBNull.Value;

            //    object errorShipDate = Convert.ToString((DateTime?)null);

            try
            {
                errorSOQty     = Convert.ToDecimal(args.Values[1]);
                errorSalePrice = Convert.ToDecimal(args.Values[2]);
                errorShipDate  = DateTime.Parse(args.Values[3].ToString());
                //  errorShipDate = DateTime.ParseExact(args.Values[3].ToString(),"MM-dd-yyyy",null);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("Cannot convert SO Data.\n" + e.Message);
                //   MessageBox.Show(errorSOQty.ToString() + " " + errorSalePrice.ToString() + " " + errorShipDate.ToString());
            }

            DataRow myRow = args.DataTable.Rows.Add(new object[]
                                                    { args.Values[0], errorSOQty, errorSalePrice, errorShipDate });

            args.Continue = true;
        }
Esempio n. 2
0
        public void FillError(object sender, FillErrorEventArgs args)
        {
            Trace.TraceError(string.Format("Sender: {0}", sender));

            Trace.Write(args);

        }
Esempio n. 3
0
        private void getData_OnFillError(FillErrorEventArgs arg)
        {
            arg.Continue = false;

            //TODO:
            //getData_OnFillError (m_MCApi, arg);
        }
 private void fillErrorHandler(object sender, FillErrorEventArgs e)
 {
     e.Continue = fillErr[fillErrCounter].contFlag;
     Assert.AreEqual(fillErr[fillErrCounter].tableName, e.DataTable.TableName, "fillErr-T");
     Assert.AreEqual(fillErr[fillErrCounter].contFlag, e.Continue, "fillErr-C");
     fillErrCounter++;
 }
Esempio n. 5
0
 protected virtual void OnFillError(FillErrorEventArgs value)
 {
     if (FillError != null)
     {
         FillError(this, value);
     }
 }
 public static void FillErrorHandler(object sender, FillErrorEventArgs e)
 {
     if (e.Errors.GetType() == typeof(NullReferenceException) || e.Errors.GetType() == typeof(FormatException))
     {
         Console.WriteLine(e.Values[0]);
     }
     e.Continue = true;
 }
Esempio n. 7
0
        internal FillErrorEventArgs CreateFillErrorEvent(DataTable dataTable, object[] values, Exception e)
        {
            FillErrorEventArgs args = new FillErrorEventArgs(dataTable, values);

            args.Errors   = e;
            args.Continue = false;
            return(args);
        }
Esempio n. 8
0
 private static void Da_FillError(object sender, FillErrorEventArgs e)
 {
     e.Continue = true;
     FormatErrorCount++;
     if (FormatErrorCount <= MAX_ERRORS)
     {
         FormatErrors.Add(string.Format("Format Error: {0}", e.Errors.Message));
     }
 }
Esempio n. 9
0
        protected virtual void OnFillError(FillErrorEventArgs value)
        {
            FillErrorEventHandler handler = (FillErrorEventHandler)base.Events[EventFillError];

            if (handler != null)
            {
                handler(this, value);
            }
        }
Esempio n. 10
0
        virtual protected void OnFillError(FillErrorEventArgs value)
        { // V1.2.3300, DbDataAdapter V1.0.3300
            FillErrorEventHandler handler = (FillErrorEventHandler)Events[EventFillError];

            if (null != handler)
            {
                handler(this, value);
            }
        }
        static void FillErrorHandler(object sender, FillErrorEventArgs e)
        {
            if (e.Errors.GetType() == typeof(System.FormatException))
            {
                Console.WriteLine("Error when attempting to update the value: {0}",
                                  e.Values[0]);
            }

            e.Continue = true;
        }
Esempio n. 12
0
 protected static void FillError(object sender, FillErrorEventArgs args)
 {
     if (args.Errors.GetType() == typeof(System.OverflowException))
     {
         //Code to handle Precision Loss
         Console.WriteLine("Error fill:" + args.Errors.Message);
         Console.ReadKey();
         args.Continue = true;
     }
 }
Esempio n. 13
0
        private static void FillErrorHandler(object sender, FillErrorEventArgs e)
        {
            // You can use the e.Errors value to determine exactly what went wrong.
            if (e.Errors.GetType() == typeof(FormatException))
            {
                Console.WriteLine("Error when attempting to update the value: {0}", e.Values[0]);
            }

            // Setting e.Continue to True tells the Load method to continue trying.
            // Setting it to False indicates that an error has occurred, and the Load method raises the exception that got you here.
            e.Continue = true;
        }
Esempio n. 14
0
        private void sqlDataAdapter1_FillError(object sender, FillErrorEventArgs e)
        {
            DialogResult response = MessageBox.Show("The following error occurred while Filling the DataSet: " + e.Errors.Message.ToString() + "Continue attempting to fill?", "FillError Encountered", MessageBoxButtons.YesNo);

            if (response == DialogResult.Yes)
            {
                e.Continue = true;
            }
            else
            {
                e.Continue = false;
            }
        }
 protected static void FillError(object sender, FillErrorEventArgs args)
 {
     if (args.Errors.GetType() == typeof(System.OverflowException))
     {
         // Code to handle precision loss.
         // Add a row to table using the values from the first two columns.
         DataRow myRow = args.DataTable.Rows.Add(new object[]
                                                 { args.Values[0], args.Values[1], DBNull.Value });
         //Set the RowError containing the value for the third column.
         myRow.RowError =
             "OverflowException Encountered. Value from data source: " +
             args.Values[2];
         args.Continue = true;
     }
 }
Esempio n. 16
0
        internal static int FillFromReader(DataTable table,
                                           IDataReader reader,
                                           int start,
                                           int length,
                                           int [] mapping,
                                           LoadOption loadOption,
                                           FillErrorEventHandler errorHandler)
        {
            if (reader.FieldCount == 0)
            {
                return(0);
            }

            for (int i = 0; i < start; i++)
            {
                reader.Read();
            }

            int counter = 0;

            object [] values = new object [mapping.Length];
            while (reader.Read() &&
                   (length == 0 || counter < length))
            {
                for (int i = 0; i < mapping.Length; i++)
                {
                    values [i] = mapping [i] < 0 ? null : reader [mapping [i]];
                }

                table.BeginLoadData();
                try {
                    table.LoadDataRow(values, loadOption);
                } catch (Exception e) {
                    FillErrorEventArgs args = new FillErrorEventArgs(table, values);
                    args.Errors   = e;
                    args.Continue = false;
                    errorHandler(table, args);
                    // if args.Continue is not set to true or if a handler is not set, rethrow the error..
                    if (!args.Continue)
                    {
                        throw e;
                    }
                }
                table.EndLoadData();
                counter++;
            }
            return(counter);
        }
Esempio n. 17
0
        private void OnFillErrorHandler(Exception e, DataTable dataTable, object[] dataValues)
        {
            FillErrorEventArgs fillErrorEvent = new FillErrorEventArgs(dataTable, dataValues);

            fillErrorEvent.Errors = e;
            OnFillError(fillErrorEvent);

            if (!fillErrorEvent.Continue)
            {
                if (null != fillErrorEvent.Errors)
                {
                    throw fillErrorEvent.Errors;
                }
                throw e;
            }
        }
Esempio n. 18
0
        private void OnFillErrorHandler(Exception e, DataTable dataTable, object[] dataValues)
        {
            FillErrorEventArgs args = new FillErrorEventArgs(dataTable, dataValues)
            {
                Errors = e
            };

            this.OnFillError(args);
            if (!args.Continue)
            {
                if (args.Errors != null)
                {
                    throw args.Errors;
                }
                throw e;
            }
        }
Esempio n. 19
0
        private void OnFillErrorHandler(Exception ex, DataTable dataTable = null, object[] dataValues = null)
        {
            FillErrorEventArgs fillErrorEvent = new FillErrorEventArgs(dataTable, dataValues)
            {
                Errors = ex
            };

            this.OnFillError(fillErrorEvent);

            if (!fillErrorEvent.Continue)
            {
                if (fillErrorEvent.Errors != null)
                {
                    throw fillErrorEvent.Errors;
                }

                throw ex;
            }
        }
Esempio n. 20
0
        /// <summary>
        /// Error handler if the returned data cannot be converted by .NET from SQL
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        protected override sealed void FillError(object sender, FillErrorEventArgs args)
        {
            // Code to handle precision loss.
            object errorarg = DBNull.Value;

            try
            {
                errorarg = Convert.ToDecimal(args.Values[1]);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("Cannot convert value to Decimal.\n" + e.Message);
            }

            DataRow myRow = args.DataTable.Rows.Add(new object[]
                                                    { args.Values[0], errorarg });

            args.Continue = true;
        }
Esempio n. 21
0
 protected virtual void OnFillError(FillErrorEventArgs value)
 {
     ((FillErrorEventHandler)Events[s_eventFillError])?.Invoke(this, value);
 }
Esempio n. 22
0
 internal virtual void OnFillErrorInternal(FillErrorEventArgs value)
 {
     OnFillError(value);
 }
Esempio n. 23
0
        private void OnFillErrorHandler(Exception e, DataTable dataTable, object[] dataValues)
        {
            FillErrorEventArgs fillErrorEvent = new FillErrorEventArgs(dataTable, dataValues);
            fillErrorEvent.Errors = e;
            OnFillError(fillErrorEvent);

            if (!fillErrorEvent.Continue)
            {
                if (null != fillErrorEvent.Errors)
                {
                    throw fillErrorEvent.Errors;
                }
                throw e;
            }
        }
        internal virtual void OnFillErrorInternal(FillErrorEventArgs value)
        {
#if NET_2_0
            OnFillError(value);
#endif
        }
Esempio n. 25
0
        internal bool FillTable(DataTable dataTable, IDataReader dataReader, int startRecord, int maxRecords, ref int counter)
        {
            if (dataReader.FieldCount == 0)
            {
                return(false);
            }

            int counterStart = counter;

            int[] mapping = BuildSchema(dataReader, dataTable, SchemaType.Mapped);

            int [] sortedMapping = new int [mapping.Length];
            int    length        = sortedMapping.Length;

            for (int i = 0; i < sortedMapping.Length; i++)
            {
                if (mapping [i] >= 0)
                {
                    sortedMapping [mapping [i]] = i;
                }
                else
                {
                    sortedMapping [--length] = i;
                }
            }

            for (int i = 0; i < startRecord; i++)
            {
                dataReader.Read();
            }

            dataTable.BeginLoadData();
            while (dataReader.Read() && (maxRecords == 0 || (counter - counterStart) < maxRecords))
            {
                try {
                    dataTable.LoadDataRow(dataReader, sortedMapping, length, AcceptChangesDuringFill);
                    counter++;
                }
                catch (Exception e) {
                    object[] readerArray = new object [dataReader.FieldCount];
                    object[] tableArray  = new object [mapping.Length];
                    // we get the values from the datareader
                    dataReader.GetValues(readerArray);
                    // copy from datareader columns to table columns according to given mapping
                    for (int i = 0; i < mapping.Length; i++)
                    {
                        if (mapping [i] >= 0)
                        {
                            tableArray [i] = readerArray [mapping [i]];
                        }
                    }
                    FillErrorEventArgs args = CreateFillErrorEvent(dataTable, tableArray, e);
                    OnFillErrorInternal(args);

                    // if args.Continue is not set to true or if a handler is not set, rethrow the error..
                    if (!args.Continue)
                    {
                        throw e;
                    }
                }
            }
            dataTable.EndLoadData();
            return(true);
        }
 private static void da_FillError(object sender, FillErrorEventArgs e)
 {
     fillError  = e.Errors.Message;
     e.Continue = true;
 }
Esempio n. 27
0
 private void Adapter_FillError(object sender, FillErrorEventArgs e)
 {
     logger.Error(e.Errors);
 }
Esempio n. 28
0
 protected virtual void OnFillError(FillErrorEventArgs value)
 {
     ((FillErrorEventHandler)Events[s_eventFillError])?.Invoke(this, value);
 }
Esempio n. 29
0
 internal override void OnFillErrorInternal(FillErrorEventArgs value)
 {
     OnFillError(value);
 }
Esempio n. 30
0
 private void Adapter_FillError(object sender, FillErrorEventArgs e)
 {
     e.Continue = true;
 }
Esempio n. 31
0
 private void fillErrorHandler(object sender, FillErrorEventArgs e)
 {
     e.Continue = _fillErr[_fillErrCounter].contFlag;
     Assert.Equal(_fillErr[_fillErrCounter].tableName, e.DataTable.TableName);
     Assert.Equal(_fillErr[_fillErrCounter].contFlag, e.Continue);
     _fillErrCounter++;
 }
Esempio n. 32
0
 private void fillErrorHandler(object sender, FillErrorEventArgs e)
 {
     e.Continue = _fillErr[_fillErrCounter].contFlag;
     Assert.Equal(_fillErr[_fillErrCounter].tableName, e.DataTable.TableName);
     //Assert.Equal (fillErr[fillErrCounter].rowKey, e.Values[0]);
     Assert.Equal(_fillErr[_fillErrCounter].contFlag, e.Continue);
     //Assert.Equal (fillErr[fillErrCounter].error, e.Errors.Message);
     _fillErrCounter++;
 }
Esempio n. 33
0
        protected void getData_OnFillError(object sender, FillErrorEventArgs e)
        {
            e.Continue = false;

            throw new ApplicationException($"::getData_OnFillError() - ...", e.Errors);
        }
Esempio n. 34
0
 void adp_FillError(object sender, FillErrorEventArgs e)
 {
     MessageBox.Show(e.Errors.Message);
 }