Example #1
0
        public static void ShowErrors(SqlCeException e)
        {
            SqlCeErrorCollection errorCollection = e.Errors;

            StringBuilder bld   = new StringBuilder();
            Exception     inner = e.InnerException;

            foreach (SqlCeError err in errorCollection)
            {
                bld.Append("\n Error Code: " + err.HResult.ToString("X"));
                bld.Append("\n Message   : " + err.Message);
                bld.Append("\n Minor Err.: " + err.NativeError);
                bld.Append("\n Source    : " + err.Source);

                foreach (int numPar in err.NumericErrorParameters)
                {
                    if (0 != numPar)
                    {
                        bld.Append("\n Num. Par. : " + numPar);
                    }
                }

                foreach (string errPar in err.ErrorParameters)
                {
                    if (String.Empty != errPar)
                    {
                        bld.Append("\n Err. Par. : " + errPar);
                    }
                }

                Console.WriteLine(bld.ToString());
                bld.Remove(0, bld.Length);
            }
        }
Example #2
0
        public static void ShowErrors(SqlCeException e)
        {
            SqlCeErrorCollection errorCollection = e.Errors;

            StringBuilder bld   = new StringBuilder();
            Exception     inner = e.InnerException;

            foreach (SqlCeError err in errorCollection)
            {
                bld.Append("\n Error Code: " + err.HResult.ToString("X",
                                                                    System.Globalization.CultureInfo.CurrentCulture));
                bld.Append("\n Message   : " + err.Message);
                bld.Append("\n Minor Err.: " + err.NativeError);
                bld.Append("\n Source    : " + err.Source);

                foreach (int numPar in err.NumericErrorParameters)
                {
                    if (0 != numPar)
                    {
                        bld.Append("\n Num. Par. : " + numPar);
                    }
                }

                foreach (string errPar in err.ErrorParameters)
                {
                    if (String.Empty != errPar)
                    {
                        bld.Append("\n Err. Par. : " + errPar);
                    }
                }
            }
            MessageBox.Show(bld.ToString());
        }
Example #3
0
        /// <summary>
        /// Point d'entrée principal de l'application.
        /// </summary>
        static void Main()
        {
            try
            {
                Application.Run(new Form1());
            }
            catch (SqlCeException e)
            {
                SqlCeErrorCollection errorCollection = e.Errors;

                StringBuilder bld   = new StringBuilder();
                Exception     inner = e.InnerException;

                if (null != inner)
                {
                    MessageBox.Show("Inner Exception: " + inner.ToString());
                }

                foreach (SqlCeError err in errorCollection)
                {
                    bld.Append("\n Error Code: " + err.HResult.ToString("X"));
                    bld.Append("\n Message   : " + err.Message);
                    bld.Append("\n Minor Err.: " + err.NativeError);
                    bld.Append("\n Source    : " + err.Source);

                    foreach (int numPar in err.NumericErrorParameters)
                    {
                        if (0 != numPar)
                        {
                            bld.Append("\n Num. Par. : " + numPar);
                        }
                    }

                    foreach (string errPar in err.ErrorParameters)
                    {
                        if (String.Empty != errPar)
                        {
                            bld.Append("\n Err. Par. : " + errPar);
                        }
                    }

                    MessageBox.Show(bld.ToString());
                    bld.Remove(0, bld.Length);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #4
0
        public List <GardenEntity> PlantsToPlantInThisMonth(GardenEntity.Month thisMonth)
        {
            List <GardenEntity> gardenEntities = new List <GardenEntity>();

            using (SqlCeConnection con = new SqlCeConnection(conString))
            {
                try
                {
                    con.Open();
                }
                catch (SqlCeException ee)
                {
                    //unable to open SqlCe connection
                    SqlCeErrorCollection errorCollection = ee.Errors;
                    StringBuilder        bld             = new StringBuilder();
                    Exception            inner           = ee.InnerException;

                    if (inner != null)
                    {
                        bld.AppendLine("Inner Exception: " + inner.ToString());
                    }

                    foreach (SqlCeError err in errorCollection)
                    {
                        bld.AppendLine(err.ToString());
                    }
                }

                string tmp = ((int)thisMonth).ToString();
                using (SqlCeCommand com = new SqlCeCommand("SELECT * FROM Plant WHERE SeedStartMonths LIKE '% " + tmp + " %'", con))
                {
                    SqlCeDataReader reader = com.ExecuteReader();

                    while (reader.Read())
                    {
                        try
                        {
                            AddReaderToGardenEntityList(gardenEntities, reader);
                        }
                        catch (Exception)
                        {
                            //unable to parse datas
                        }
                    }
                }
            }
            return(gardenEntities);
        }
Example #5
0
        public List <GardenEntity> ListAnnual()
        {
            List <GardenEntity> gardenEntities = new List <GardenEntity>();

            using (SqlCeConnection con = new SqlCeConnection(conString))
            {
                try
                {
                    con.Open();
                }
                catch (SqlCeException ee)
                {
                    //unable to open SqlCe connection
                    SqlCeErrorCollection errorCollection = ee.Errors;
                    StringBuilder        bld             = new StringBuilder();
                    Exception            inner           = ee.InnerException;

                    if (inner != null)
                    {
                        bld.AppendLine("Inner Exception: " + inner.ToString());
                    }

                    foreach (SqlCeError err in errorCollection)
                    {
                        bld.AppendLine(err.ToString());
                    }
                }

                using (SqlCeCommand com = new SqlCeCommand("SELECT Plant.ID, Plant.Name, Plant.Description, Plant.Maintenance, Plant.Type, Plant.LightExposure, Plant.SeedStartMonths, Plant.WithstandColdestZone, Plant.WithstandHottestZone, PlantType.ID AS Expr1, PlantType.Type AS Expr2 FROM  Plant INNER JOIN PlantType ON Plant.Type = PlantType.ID WHERE (PlantType.Type = 'Annual')", con))
                {
                    SqlCeDataReader reader = com.ExecuteReader();

                    while (reader.Read())
                    {
                        try
                        {
                            AddReaderToGardenEntityList(gardenEntities, reader);
                        }
                        catch (Exception)
                        {
                            //unable to parse datas
                        }
                    }
                }
            }
            return(gardenEntities);
        }
Example #6
0
        public List <GardenEntity> ViewAllPlantsInGarden()
        {
            List <GardenEntity> gardenEntities = new List <GardenEntity>();

            using (SqlCeConnection con = new SqlCeConnection(conString))
            {
                try
                {
                    con.Open();
                }
                catch (SqlCeException ee)
                {
                    //unable to open SqlCe connection
                    SqlCeErrorCollection errorCollection = ee.Errors;
                    StringBuilder        bld             = new StringBuilder();
                    Exception            inner           = ee.InnerException;

                    if (inner != null)
                    {
                        bld.AppendLine("Inner Exception: " + inner.ToString());
                    }

                    foreach (SqlCeError err in errorCollection)
                    {
                        bld.AppendLine(err.ToString());
                    }
                }

                using (SqlCeCommand com = new SqlCeCommand("SELECT * FROM Plant", con))
                {
                    SqlCeDataReader reader = com.ExecuteReader();

                    while (reader.Read())
                    {
                        try
                        {
                            AddReaderToGardenEntityList(gardenEntities, reader);
                        }
                        catch (Exception)
                        {
                            //unable to parse datas
                        }
                    }
                }
            }
            return(gardenEntities);
        }
Example #7
0
        public List <GardenEntity> ListPlantsInZone(GardenEntity.hardinessZone myZone)
        {
            List <GardenEntity> gardenEntities = new List <GardenEntity>();

            using (SqlCeConnection con = new SqlCeConnection(conString))
            {
                try
                {
                    con.Open();
                }
                catch (SqlCeException ee)
                {
                    //unable to open SqlCe connection
                    SqlCeErrorCollection errorCollection = ee.Errors;
                    StringBuilder        bld             = new StringBuilder();
                    Exception            inner           = ee.InnerException;

                    if (inner != null)
                    {
                        bld.AppendLine("Inner Exception: " + inner.ToString());
                    }

                    foreach (SqlCeError err in errorCollection)
                    {
                        bld.AppendLine(err.ToString());
                    }
                }

                using (SqlCeCommand com = new SqlCeCommand("SELECT * FROM Plant WHERE Plant.WithstandColdestZone <= '" + (int)myZone + "' AND Plant.WithstandHottestZone >= '" + (int)myZone + "'", con))
                {
                    SqlCeDataReader reader = com.ExecuteReader();

                    while (reader.Read())
                    {
                        try
                        {
                            AddReaderToGardenEntityList(gardenEntities, reader);
                        }
                        catch (Exception)
                        {
                            //unable to parse datas
                        }
                    }
                }
            }
            return(gardenEntities);
        }
Example #8
0
        /// <summary>
        /// Handle for the server messages.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">
        /// The <see cref="System.Data.SqlClient.SqlInfoMessageEventArgs"/> instance containing the message data.
        /// </param>
        private void InfoMessageHandler(object sender, SqlCeInfoMessageEventArgs e)
        {
            SqlCeErrorCollection errors = e.Errors;

            if (errors == null || errors.Count == 0)
            {
                DbMessageEventArgs eventArgs = new DbMessageEventArgs(e.Message);
                OnDbMessage(eventArgs);
            }
            else
            {
                foreach (SqlCeError error in errors)
                {
                    TraceLevel         severity  = GetSeverity(error);
                    SqlCeMessage       message   = new SqlCeMessage(error);
                    DbMessageEventArgs eventArgs = new DbMessageEventArgs(message);
                    OnDbMessage(eventArgs);
                }
            }
        }
Example #9
0
        public static void ShowErrors(SqlCeException e)
        {
            SqlCeErrorCollection errors  = e.Errors;
            Exception            inner   = e.InnerException;
            StringBuilder        builder = new StringBuilder();

            if (inner != null)
            {
                MessageBox.Show(inner.ToString(), "Inner Exception");
            }

            foreach (SqlCeError error in errors)
            {
                builder.Append("\r Error Code: " + error.HResult.ToString("X"));
                builder.Append("\r Message   : " + error.Message);
                builder.Append("\r Minor Err.: " + error.NativeError);
                builder.Append("\r Source    : " + error.Source);

                foreach (int param in error.NumericErrorParameters)
                {
                    if (param != 0)
                    {
                        builder.Append("\r Num. Par. : " + param.ToString());
                    }
                }

                foreach (string errPar in error.ErrorParameters)
                {
                    if (errPar != String.Empty)
                    {
                        builder.Append("\r Err. Par. : " + errPar);
                    }
                }

                if (builder.ToString().Length > 0)
                {
                    MessageBox.Show(builder.ToString(), "SqlCE Error");
                }
                builder.Remove(0, builder.Length);
            }
        }
Example #10
0
        internal static void ShowErrors(SqlCeException e)
        {
            SqlCeErrorCollection errorCollection = e.Errors;

            StringBuilder bld   = new StringBuilder();
            Exception     inner = e.InnerException;

            if (null != inner)
            {
                Console.Error.WriteLine("Inner Exception: " + inner.ToString());
            }
            // Enumerate the errors to a message box.
            foreach (System.Data.SqlServerCe.SqlCeError err in errorCollection)
            {
                bld.Append("\n Error Code: " + err.HResult.ToString("X", System.Globalization.CultureInfo.InvariantCulture));
                bld.Append("\n Message   : " + err.Message);
                bld.Append("\n Minor Err.: " + err.NativeError);
                bld.Append("\n Source    : " + err.Source);

                // Enumerate each numeric parameter for the error.
                foreach (int numPar in err.NumericErrorParameters)
                {
                    if (0 != numPar)
                    {
                        bld.Append("\n Num. Par. : " + numPar);
                    }
                }

                // Enumerate each string parameter for the error.
                foreach (string errPar in err.ErrorParameters)
                {
                    if (!string.IsNullOrEmpty(errPar))
                    {
                        bld.Append("\n Err. Par. : " + errPar);
                    }
                }

                Console.Error.WriteLine(bld.ToString());
                bld.Remove(0, bld.Length);
            }
        }
Example #11
0
        public void ShowErrors(SqlCeException e)
        {
            SqlCeErrorCollection errorCollection = e.Errors;
            StringBuilder        bld             = new StringBuilder();
            Exception            inner           = e.InnerException;

            if (inner != null)
            {
                MessageBox.Show(("Inner Exception: " + inner.ToString()));
            }

            foreach (SqlCeError err  in errorCollection)
            {
                bld.Append("\n" + " Error Code: " + err.HResult.ToString());
                bld.Append("\n" + " Message   : " + err.Message);
                bld.Append("\n" + " Minor Err.: " + err.NativeError);
                bld.Append("\n" + " Source    : " + err.Source);

                foreach (int numPar in err.NumericErrorParameters)
                {
                    if (0 != numPar)
                    {
                        bld.Append("\n" + " Num. Par. : " + numPar);
                    }
                }

                foreach (string errPar in err.ErrorParameters)
                {
                    if (string.Empty != errPar)
                    {
                        bld.Append("\n" + " Err. Par. : " + errPar);
                    }
                }

                MessageBox.Show(bld.ToString());
                bld.Remove(0, bld.Length);
            }
        }
Example #12
0
        // pas dispo avec le compact framework
        // [STAThread]
        static void Main()
        {
            try
            {
                splash = new SplashForm();
                splash.Show();

                splash.Label = "Connexion à la base...";
                splash.Label = "Vérification des versions...";
                if (!CheckVersion())
                {
                    throw new Exception("Erreur de version");
                }
                splash.Label = "Création de la fenêtre principale...";
                mainform     = new Repertoire();

                System.Threading.Thread splashClose = new System.Threading.Thread(new System.Threading.ThreadStart(CloseSplash));
                splashClose.Start();
                System.Windows.Forms.Application.Run(mainform);
            }
            catch (SqlCeException e)
            {
                SqlCeErrorCollection errorCollection = e.Errors;

                StringBuilder bld   = new StringBuilder();
                Exception     inner = e.InnerException;

                if (null != inner)
                {
                    MessageBox.Show("Inner Exception: " + inner.ToString());
                }

                foreach (SqlCeError err in errorCollection)
                {
                    bld.Append("\n Error Code: " + err.HResult.ToString("X", CultureInfo.CurrentCulture));
                    bld.Append("\n Message   : " + err.Message);
                    bld.Append("\n Minor Err.: " + err.NativeError);
                    bld.Append("\n Source    : " + err.Source);

                    foreach (int numPar in err.NumericErrorParameters)
                    {
                        if (0 != numPar)
                        {
                            bld.Append("\n Num. Par. : " + numPar);
                        }
                    }

                    foreach (string errPar in err.ErrorParameters)
                    {
                        if (errPar.Length > 0)
                        {
                            bld.Append("\n Err. Par. : " + errPar);
                        }
                    }

                    MessageBox.Show(bld.ToString());
                    bld.Remove(0, bld.Length);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }