// A method that saves the information of Build into the database ------------------------------------------------------
        public void SaveBuild(Build build)
        {
            Open();
            string Buildname = build.BuildName;
            string Author = build.Author;
            string Class = build.SelectedClass;
            string Spec = build.SelectedSpec;
            string Spell1 = null;
            string Spell2 = null;
            string Spell3 = null;
            string Spell4 = null;
            string Spell5 = null;
            string Spell6 = null;

            foreach (string spell in build.SelectedSpells)
            {
                if (Spell1 == null)
                {
                    Spell1 = spell;
                }
                else if (Spell2 == null)
                {
                    Spell2 = spell;
                }
                else if (Spell3 == null)
                {
                    Spell3 = spell;
                }
                else if (Spell4 == null)
                {
                    Spell4 = spell;
                }
                else if (Spell5 == null)
                {
                    Spell5 = spell;
                }
                else if (Spell6 == null)
                {
                    Spell6 = spell;
                }
            }

            try
            {
                OleDbConnection myconnection = new OleDbConnection(accesconnectionstring);
                OleDbCommand Command = myconnection.CreateCommand();
                myconnection.Open();
                Command.CommandText = "INSERT INTO Build ([BuildName],[Author],[Class],[Spec],[Spell1],[Spell2],[Spell3],[Spell4],[Spell5],[Spell6])" +
                    "VALUES('" + Buildname + "','" + Author + "','" + Class + "','" + Spec + "','" + Spell1 + "','" + Spell2 + "','" + Spell3 + "','" + Spell4 + "','" + Spell5 + "','" + Spell6 + "')";
                Command.ExecuteNonQuery();
            }
            catch
            {

            }
            Close();
        }
Esempio n. 2
0
        public void SaveBuild(Build build)
        {
            Open();
            string Buildname = build.BuildName;
            string Author = build.Author;
            string Class = build.SelectedClass;
            string Spec = build.SelectedSpec;
            string Spell1 = null;
            string Spell2 = null;
            string Spell3 = null;
            string Spell4 = null;
            string Spell5 = null;
            string Spell6 = null;

            foreach (string spell in build.SelectedSpells)
            {
                if(Spell1 == null)
                {
                    Spell1 = spell;
                }
                else if (Spell2 == null)
                {
                    Spell2 = spell;
                }
                else if (Spell3 == null)
                {
                    Spell3 = spell;
                }
                else if (Spell4 == null)
                {
                    Spell4 = spell;
                }
                else if (Spell5 == null)
                {
                    Spell5 = spell;
                }
                else if (Spell6 == null)
                {
                    Spell6 = spell;
                }
            }

            try
            {
                OleDbConnection myconnection = new OleDbConnection(accesconnectionstring);
                /*Command.Parameters.AddWithValue("@BuildName", Buildname);
                Command.Parameters.AddWithValue("@BuildAuthor", Author);
                Command.Parameters.AddWithValue("@Class", Class);
                Command.Parameters.AddWithValue("@Spec", Spec);
                Command.Parameters.AddWithValue("@Spell1", Spell1);
                Command.Parameters.AddWithValue("@Spell2", Spell2);
                Command.Parameters.AddWithValue("@Spell3", Spell3);
                Command.Parameters.AddWithValue("@Spell4", Spell4);
                Command.Parameters.AddWithValue("@Spell5", Spell5);
                Command.Parameters.AddWithValue("@Spell6", Spell6);

                Command.Connection = connection;
                Command.ExecuteNonQuery();*/

                OleDbCommand Command = myconnection.CreateCommand();
                myconnection.Open();
                Command.CommandText = "INSERT INTO Build ([BuildName],[Author],[Class],[Spec],[Spell1],[Spell2],[Spell3],[Spell4],[Spell5],[Spell6])" +
                    "VALUES('" + Buildname + "','" + Author + "','" + Class + "','" + Spec + "','" + Spell1 + "','" + Spell2 + "','" + Spell3 + "','" + Spell4 + "','" + Spell5 + "','" + Spell6 + "')";
                Command.ExecuteNonQuery();
            }
            catch
            {

            }
            Close();
        }