• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# MySqlClient.MySqlCommand类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中MySql.Data.MySqlClient.MySqlCommand的典型用法代码示例。如果您正苦于以下问题:C# MySqlCommand类的具体用法?C# MySqlCommand怎么用?C# MySqlCommand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MySqlCommand类属于MySql.Data.MySqlClient命名空间,在下文中一共展示了MySqlCommand类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: LoadItemsSets

        public static void LoadItemsSets()
        {
            lock (DatabaseHandler.ConnectionLocker)
            {
                var sqlText = "SELECT * FROM datas_items_sets";
                var sqlCommand = new MySqlCommand(sqlText, DatabaseHandler.Connection);

                var sqlReader = sqlCommand.ExecuteReader();

                while (sqlReader.Read())
                {
                    var set = new Models.Items.SetModel();

                    set.ID = sqlReader.GetInt16("ID");
                    set.ParseBonus(sqlReader.GetString("bonus"));
                    set.ParseItems(sqlReader.GetString("items"));

                    lock(SetsList)
                        SetsList.Add(set);
                }

                sqlReader.Close();
            }

            Utilities.Loggers.StatusLogger.Write(string.Format("Loaded @'{0}' items [email protected] from the database !", SetsList.Count));
        }
开发者ID:T4NK,项目名称:SunDofus,代码行数:26,代码来源:ItemsCache.cs


示例2: Button_click

        protected void Button_click(object sender, EventArgs e)
        {
            MySqlConnection bazaPovezava = new MySqlConnection(bazaConnString);
            try
            {
                bazaPovezava.Open();
                string SQLcommand = "INSERT INTO User(username, firstname, lastname, password, email, city, country) VALUES(?un, ?fn, ?ln, ?pw, ?em, ?ci, ?co);";
                MySqlCommand bazaUkaz = new MySqlCommand(SQLcommand, bazaPovezava);
                bazaUkaz.Parameters.Add(new MySqlParameter("?un", username.Text));
                bazaUkaz.Parameters.Add(new MySqlParameter("?fn", firstname.Text));
                bazaUkaz.Parameters.Add(new MySqlParameter("?ln", surname.Text));
                bazaUkaz.Parameters.Add(new MySqlParameter("?pw", pass.Text));
                bazaUkaz.Parameters.Add(new MySqlParameter("?em", email.Text));
                bazaUkaz.Parameters.Add(new MySqlParameter("?ci", city.Text));
                bazaUkaz.Parameters.Add(new MySqlParameter("?co", country.Text));

                bazaUkaz.ExecuteNonQuery();
            }
            catch(Exception ex)
            {
                Console.WriteLine(ex);
            }
            finally
            {
                bazaPovezava.Close();
            }
        }
开发者ID:Kokanm,项目名称:eClassroomASP.NET,代码行数:27,代码来源:create.aspx.cs


示例3: LoadAccount

        public static Models.AccountsModel LoadAccount(int accountID)
        {
            DatabaseProvider.CheckConnection();

            lock (DatabaseProvider.ConnectionLocker)
            {
                var account = new Models.AccountsModel();

                var sqlText = "SELECT * FROM dyn_accounts WHERE [email protected]";
                var sqlCommand = new MySqlCommand(sqlText, DatabaseProvider.Connection);
                sqlCommand.Parameters.Add(new MySqlParameter("@id", accountID));

                var sqlReader = sqlCommand.ExecuteReader();

                if (sqlReader.Read())
                {
                    account.ID = sqlReader.GetInt16("id");
                    account.Username = sqlReader.GetString("username");
                    account.Password = sqlReader.GetString("password");
                    account.Pseudo = sqlReader.GetString("pseudo");
                    account.Communauty = sqlReader.GetInt16("communauty");
                    account.Level = sqlReader.GetInt16("gmLevel");
                    account.Question = sqlReader.GetString("question");
                    account.Answer = sqlReader.GetString("answer");
                    account.SubscriptionDate = sqlReader.GetDateTime("subscription");
                }

                sqlReader.Close();

                return account;
            }
        }
开发者ID:T4NK,项目名称:SunDofus,代码行数:32,代码来源:AccountsRequests.cs


示例4: InserirPedido

        public int InserirPedido(int numCliente, List<Item> pedido)
        {
            int NumPedido = 0;
            int idPedido = 0;
            MySqlConnection conn = new MySqlConnection(connectionString);
            MySqlCommand cmd = new MySqlCommand();

            cmd.Connection = conn;
            conn.Open();

            cmd.CommandText = "Select Max(numero) + 1 from tb_Pedidos";
            NumPedido = int.Parse(cmd.ExecuteScalar().ToString());

            cmd.CommandText = "Insert into tb_Pedidos (numero, id_cliente, data) Values(" + NumPedido + "," + numCliente + ", sysdate()); select Max(id) from tb_Pedidos;";
            idPedido = int.Parse(cmd.ExecuteScalar().ToString());

            foreach (Item item in pedido)
            {
                cmd.CommandText = "insert into tb_items (nome, descricao, preco, quantidade, id_pedido, urlImagem) Values ('" + item.descricao + "', Null,"+ item.preco.ToString().Replace(",",".") + "," + item.quantidade + "," + idPedido + ", Null);";
                cmd.ExecuteNonQuery();
            }

            conn.Close();

            return NumPedido;
        }
开发者ID:JulioSI,项目名称:TP_Carefour,代码行数:26,代码来源:PedidoDAO.cs


示例5: validateLogin

        public static bool validateLogin(UserLog ul)
        {
            DBConnector dbcon = new DBConnector();
            dbcon.openConnection();

            //try {

            MySqlCommand cmd = new MySqlCommand();
            cmd.CommandText = "SELECT * FROM user WHERE username='" + ul.getUsername() + "' AND password=MD5('" + ul.getPassword() + "')";
            cmd.Connection = dbcon.connection;

            MySqlDataReader login = cmd.ExecuteReader();

            if (login.Read())
            {
                LoginSession.setSession(login.GetString("iduser"));

                //login.Close();
                dbcon.closeConnection();
                return true;
            }
            else
            {
                //login.Close();
                dbcon.closeConnection();
                return false;
            }
            //}
            //catch (MySqlException e){
            //int errorcode = e.Number;
            //return false;
            //}
        }
开发者ID:lakmalbuddikalucky,项目名称:OOSD-Project,代码行数:33,代码来源:LoginValidator.cs


示例6: Update

        /// <summary> 
        /// 修改数据 
        /// </summary> 
        /// <param name="entity"></param> 
        /// <returns></returns> 
        public int Update(Policy entity)
        {
            string sql = "UPDATE  tb_policy SET [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],";
            sql = sql + " [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected] where [email protected] ";

            //string sql = "UPDATE cimuser SET [email protected] WHERE [email protected]";
            using (MySqlConnection mycn = new MySqlConnection(mysqlConnection))
            {
                mycn.Open();
                MySqlCommand command = new MySqlCommand(sql, mycn);
                command.Parameters.AddWithValue("@agentType", entity.agentType);
                command.Parameters.AddWithValue("@sequence", entity.sequence);
                command.Parameters.AddWithValue("@subject", entity.subject);
                command.Parameters.AddWithValue("@content", entity.content);
                command.Parameters.AddWithValue("@sender", entity.sender);
                command.Parameters.AddWithValue("@attachment", entity.attachment);
                command.Parameters.AddWithValue("@attachmentName", entity.attachmentName);
                command.Parameters.AddWithValue("@creatTime", entity.creatTime);
                command.Parameters.AddWithValue("@type", entity.type);
                command.Parameters.AddWithValue("@validateStartTime", entity.validateStartTime);
                 command.Parameters.AddWithValue("@validateEndTime", entity.validateEndTime);
                command.Parameters.AddWithValue("@isValidate", entity.isValidate);
                command.Parameters.AddWithValue("@isDelete", entity.isDelete);
                command.Parameters.AddWithValue("@deleteTime", entity.deleteTime);
                command.Parameters.AddWithValue("@toAll", entity.toAll);
                int i = command.ExecuteNonQuery();
                mycn.Close();
                mycn.Dispose();
                return i;
            }
        }
开发者ID:ZhouAnPing,项目名称:Mail,代码行数:36,代码来源:PolicyDao.cs


示例7: buscarPorId

        public static Trayecto buscarPorId(int id)
        {
            Trayecto trayecto = null;
            if (id > -1)
            {
                MySqlConnection con = conexionDB.ObtenerConexion();
                try
                {
                    string sql = "select id, origen, destino, precio from trayecto where id = " + id;
                    MySqlCommand cmd = new MySqlCommand(sql, con);
                    MySqlDataReader dr = cmd.ExecuteReader();

                    while (dr.Read())
                    {
                        trayecto = new Trayecto(dr.GetInt32(0), CiudadFacade.buscarPorId(dr.GetInt32(1)), CiudadFacade.buscarPorId(dr.GetInt32(2)), dr.GetInt32(3));
                    }
                    dr.Close();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    trayecto = null;
                }
                finally
                {
                    con.Close();
                }
            }
            return trayecto;
        }
开发者ID:jhope2009,项目名称:SmarTravelFinal,代码行数:30,代码来源:TrayectoFacade.cs


示例8: LoadAccount

        public Account LoadAccount(string username)
        {
            string SqlQuery = "SELECT * FROM `accounts` WHERE `username` = ?username";
                MySqlCommand SqlCommand = new MySqlCommand(SqlQuery, AccountDAOConnection);
                SqlCommand.Parameters.AddWithValue("?username", username);
                MySqlDataReader AccountReader = SqlCommand.ExecuteReader();

                Account acc = new Account();
                if (AccountReader.HasRows)
                {
                    while (AccountReader.Read())
                    {
                        acc.AccountId = AccountReader.GetInt32(0);
                        acc.Username = AccountReader.GetString(1);
                        acc.Password = AccountReader.GetString(2);
                        acc.Email = AccountReader.GetString(3);
                        acc.AccessLevel = (byte)AccountReader.GetInt32(4);
                        acc.Membership = (byte)AccountReader.GetInt32(5);
                        acc.isGM = AccountReader.GetBoolean(6);
                        acc.LastOnlineUtc = AccountReader.GetInt64(7);
                        acc.Coins = (int)AccountReader.GetInt32(8);
                        acc.Ip = AccountReader.GetString(9);
                        acc.UiSettings = ByteUtilities.StringToByteArray(AccountReader.GetString(10));

                    }
                }
                AccountReader.Close();
                return (acc.Username == "") ? null : acc;
        }
开发者ID:sdbezerra,项目名称:Temu,代码行数:29,代码来源:AccountDAO.cs


示例9: buscarOrigenes

        public static List<Trayecto> buscarOrigenes()
        {
            List<Trayecto> trayectos = new List<Trayecto>(); ;

            MySqlConnection con = conexionDB.ObtenerConexion();
            try
            {
                string sql = "select id, origen, destino, precio from trayecto group by origen";
                MySqlCommand cmd = new MySqlCommand(sql, con);
                MySqlDataReader dr = cmd.ExecuteReader();

                while (dr.Read())
                {
                    trayectos.Add(new Trayecto(dr.GetInt32(0), CiudadFacade.buscarPorId(dr.GetInt32(1)), CiudadFacade.buscarPorId(dr.GetInt32(2)), dr.GetInt32(3)));
                }
                dr.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                con.Close();
            }

            return trayectos;
        }
开发者ID:jhope2009,项目名称:SmarTravelFinal,代码行数:28,代码来源:TrayectoFacade.cs


示例10: Insert

		public Int16 Insert(ParkingRateDetails Details)
		{
			try 
			{
                Details.CreatedByName = Details.ParkingRateID == 0 ? Details.CreatedByName : Details.LastUpdatedByName;

                Save(Details);

                string SQL = "SELECT LAST_INSERT_ID();";

                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = SQL;

                System.Data.DataTable dt = new System.Data.DataTable("LAST_INSERT_ID");
                base.MySqlDataAdapterFill(cmd, dt);
                

                Int16 iID = 0;
                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    iID = Int16.Parse(dr[0].ToString());
                }

				return iID;
			}

			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}
开发者ID:marioricci,项目名称:erp-luma,代码行数:32,代码来源:ParkingRates.cs


示例11: Add

        public const string mysqlConnection = DBConstant.mysqlConnection;//"User Id=root;Host=115.29.229.134;Database=chinaunion;password=c513324665;charset=utf8";
        /// <summary> 
        /// 添加数据 
        /// </summary> 
        /// <returns></returns> 
        public int Add(Policy entity)
        {


            string sql = "INSERT INTO tb_policy (agentType,subject,content,sender,attachment,attachmentName,creatTime,type, validateStartTime,validateEndTime, isValidate, isDelete, deleteTime,toAll) VALUE (@agentType,@subject,@content,@sender,@attachment,@attachmentName,@creatTime,@type, @validateStartTime,@validateEndTime, @isValidate, @isDelete, @deleteTime,@toAll)";
            using (MySqlConnection mycn = new MySqlConnection(mysqlConnection))
            {
                mycn.Open();
                MySqlCommand command = new MySqlCommand(sql, mycn);
                command.Parameters.AddWithValue("@agentType", entity.agentType);
                command.Parameters.AddWithValue("@subject", entity.subject);
                command.Parameters.AddWithValue("@content", entity.content);
                command.Parameters.AddWithValue("@sender", entity.sender);
                command.Parameters.AddWithValue("@attachment", entity.attachment);
                command.Parameters.AddWithValue("@attachmentName", entity.attachmentName);
                command.Parameters.AddWithValue("@creatTime", entity.creatTime);
                command.Parameters.AddWithValue("@type", entity.type);
                command.Parameters.AddWithValue("@validateStartTime", entity.validateStartTime);
                command.Parameters.AddWithValue("@validateEndTime", entity.validateEndTime);
                command.Parameters.AddWithValue("@isValidate", entity.isValidate);
                command.Parameters.AddWithValue("@isDelete", entity.isDelete);
                command.Parameters.AddWithValue("@deleteTime", entity.deleteTime);
                command.Parameters.AddWithValue("@toAll", entity.toAll);


                int i = command.ExecuteNonQuery();
                mycn.Close();
                mycn.Dispose();
                return i;
            }
        }
开发者ID:ZhouAnPing,项目名称:Mail,代码行数:36,代码来源:PolicyDao.cs


示例12: buttonCadastrar_Click

        private void buttonCadastrar_Click(object sender, EventArgs e)
        {
            MySqlConnection conn = null;

            try
            {
                conn = Conexao.getConexao();
                MySqlCommand cmd = new MySqlCommand("call cadastra_pizza(@nome, @tamanho, @preco)", conn);
                cmd.Prepare();
                cmd.Parameters.AddWithValue("@nome", this.txt_nome.Text);
                cmd.Parameters.AddWithValue("@tamanho", this.cmb_tamanho.Text);
                cmd.Parameters.AddWithValue("@preco", this.txt_preco.Text);

                MySqlDataReader rs = cmd.ExecuteReader();
                rs.Read();

                if (!rs.HasRows)
                {
                    conn.Close();
                    new SuccessDialog("Pizza cadastrada com sucesso!");
                    this.Close();
                }
                else
                {
                    String error = rs.GetString(0);
                    conn.Close();
                    new ErrorDialog(error);
                }
            }
            catch (Exception err)
            {
                if (conn != null) conn.Close();
                new ErrorDialog(err.Message);
            }
        }
开发者ID:fmontezuma,项目名称:fmontezuma,代码行数:35,代码来源:CadPizza.cs


示例13: Dodaj

        protected void Dodaj(object sender, EventArgs e)
        {
            string DruzynaID = txtDruzyna.Text;
            string Imie = txtImie.Text;
            string Nazwisko = txtNazwisko.Text;
            string Data = txtData.Text;
            string Pozycja = txtPozycja.Text;
            string Waga = txtWaga.Text;
            string Wzrost = txtWzrost.Text;
            string Numer = txtNumer.Text;

            string sDate = String.Format("{0:yyyy-mm-dd}", Data);

            MySqlConnection polaczenie = new MySqlConnection(url);
            MySqlCommand cmd = new MySqlCommand("INSERT INTO pilkarze (ID_Druzyny, Imie, Nazwisko, Data_urodz, Pozycja, Waga, Wzrost, Nr_Kosz) VALUES (@IdDruzyny, @imie, @nazwisko, @data, @pozycja, @waga, @wzrost, @numer)", polaczenie);
            MySqlDataAdapter sda = new MySqlDataAdapter();
            cmd.Parameters.AddWithValue("@IdDruzyny", DruzynaID);
            cmd.Parameters.AddWithValue("@imie", Imie);
            cmd.Parameters.AddWithValue("@nazwisko", Nazwisko);
            cmd.Parameters.AddWithValue("@data", sDate);
            cmd.Parameters.AddWithValue("@pozycja", Pozycja);
            cmd.Parameters.AddWithValue("@waga", Waga);
            cmd.Parameters.AddWithValue("@wzrost", Wzrost);
            cmd.Parameters.AddWithValue("@numer", Numer);

            polaczenie.Open();
            cmd.ExecuteNonQuery();
            polaczenie.Close();
            this.WypelnijGridView();
        }
开发者ID:danielblokus,项目名称:Aplikacja-internetowa-technologia-ASP.NET,代码行数:30,代码来源:PilkarzeAdmin.aspx.cs


示例14: fillgridDef

        private void fillgridDef()
        {
            id = -1;
            buttonDel.Visible = false;
            buttonEdit.Visible = false;
            buttonIns.Visible = false;
            buttonCancel.Visible = false;
            DBConnect NewcConnection = new DBConnect();
            NewcConnection.dbConnection();
            MySqlCommand querysql = new MySqlCommand("Select * From deficiencias", DBConnect.db);

            try
            {
                MySqlDataAdapter dados = new MySqlDataAdapter();
                dados.SelectCommand = querysql;
                DataTable tabela = new DataTable();
                dados.Fill(tabela);
                BindingSource fonte = new BindingSource();
                fonte.DataSource = tabela;
                dataGridView1.DataSource = fonte;
                this.dataGridView1.Columns[0].Visible = false;
                dataGridView1.Columns[1].HeaderText = "Deficiencia";
                dados.Update(tabela);
                dataGridView1.AutoResizeColumns();
                dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            DBConnect.db.Close();
            textBoxDef.Clear();
        }
开发者ID:hortopericial,项目名称:horto-c-sharp,代码行数:34,代码来源:Deficiencia.cs


示例15: create

        public void create()
        {
            db = new Database();

            if (officeVerification())
            {
                try
                {
                    officeQuery = new MySqlCommand();

                    officeQuery.Connection = db.Connection();

                    officeQuery.CommandText = "INSERT INTO office(officedescription) VALUES(@Description)";

                    officeQuery.Prepare();

                    officeQuery.Parameters.AddWithValue("@Description", officedescription);

                    officeQuery.ExecuteNonQuery();

                    MessageBox.Show("A Descrição Cargo Assinatura " + officedescription + " foi criada com sucesso.");
                }
                catch (MySqlException ex)
                {
                    MessageBox.Show("Ocurreu um erro");
                    Console.WriteLine("Error: {0}", ex.ToString());
                }
                finally
                {
                    db.Close();
                }
            }
        }
开发者ID:JoseMariaAndrade,项目名称:VeneporteProject,代码行数:33,代码来源:Office.cs


示例16: AddCharacter

        public static void AddCharacter(Models.Character character)
        {
            var query = new MySqlCommand("INSERT INTO characters (id, account, nickname, level, experience, sex, breed, skincolor," +
                " haircolor, pupilcolor, skincolorfactor, haircolorfactor, cloth, face, title) VALUES " +
                "(@id, @account, @nickname, @level, @experience, @sex, @breed, @skincolor, @haircolor," +
                " @pupilcolor, @skincolorfactor, @haircolorfactor, @cloth, @face, @title)", DatabaseManager.Connection);

            query.Parameters.Add(new MySqlParameter("@id", character.ID));
            query.Parameters.Add(new MySqlParameter("@account", character.Account));
            query.Parameters.Add(new MySqlParameter("@nickname", character.Nickname));
            query.Parameters.Add(new MySqlParameter("@level", character.Level));
            query.Parameters.Add(new MySqlParameter("@experience", character.Experience));
            query.Parameters.Add(new MySqlParameter("@sex", character.Sex));
            query.Parameters.Add(new MySqlParameter("@breed", character.Breed));
            query.Parameters.Add(new MySqlParameter("@skincolor", character.SkinColor));
            query.Parameters.Add(new MySqlParameter("@haircolor", character.HairColor));
            query.Parameters.Add(new MySqlParameter("@pupilcolor", character.PupilColor));
            query.Parameters.Add(new MySqlParameter("@skincolorfactor", character.SkinColorFactor));
            query.Parameters.Add(new MySqlParameter("@haircolorfactor", character.HairColorFactor));
            query.Parameters.Add(new MySqlParameter("@cloth", character.Cloth));
            query.Parameters.Add(new MySqlParameter("@face", character.Face));
            query.Parameters.Add(new MySqlParameter("@title", character.Title));

            query.ExecuteNonQuery();

            Characters.Add(character);
        }
开发者ID:sirgebet,项目名称:WakSharp,代码行数:27,代码来源:Storage.cs


示例17: actionCreate

        public bool actionCreate(Task task)
        {
            var conn = new MySqlConnection(TaskDAO.StringConnection);

            try
            {
                conn.Open();

                var sql = "INSERT INTO tasks (title, description, created_at, user_id) VALUES (@title, @description, @created_at, @user_id)";

                var cmd = new MySqlCommand(sql, conn);
                cmd.Parameters.AddWithValue("@title", task.Title);
                cmd.Parameters.AddWithValue("@description", task.Description);
                cmd.Parameters.AddWithValue("@created_at", DateTime.Now);
                cmd.Parameters.AddWithValue("@user_id", task.User.Id);

                cmd.ExecuteNonQuery();

                return true;
            } catch(Exception ex)
            {
                Console.WriteLine(ex.Message);
                return false;
            }
            finally
            {
                conn.Close();
            }
        }
开发者ID:mdamaceno,项目名称:TodoList,代码行数:29,代码来源:TaskEntity.cs


示例18: EditAlat

        public EditAlat(Alat alat)
        {
            InitializeComponent();
            this.alat = alat;

            status = new List<KV>();
            status.Add(new KV("Baik", 1));
            status.Add(new KV("Rusak", 0));
            comboBox_Status.ItemsSource = status;
            comboBox_Status.DisplayMemberPath = "Key";
            comboBox_Status.SelectedValuePath = "Value";
            comboBox_Status.SelectedValue = (alat.KondisiAlat) ? 1 : 0;

            textbox_Laboratorium.Text = alat.Lokasi;

            string query = "SELECT * FROM master_inventory_type";
            using (MySqlCommand cmd = new MySqlCommand(query, db.ConnectionManager.Connection)) {
                try {
                    DataTable dataSet = new DataTable();
                    using (MySqlDataAdapter dataAdapter = new MySqlDataAdapter(cmd)) {
                        dataAdapter.Fill(dataSet);
                        comboBox_Jenis_Barang.ItemsSource = dataSet.DefaultView;
                        comboBox_Jenis_Barang.DisplayMemberPath = dataSet.Columns["nama"].ToString();
                        comboBox_Jenis_Barang.SelectedValuePath = dataSet.Columns["id"].ToString();
                        comboBox_Jenis_Barang.SelectedValue = alat.IdJenis;
                    }
                }
                catch (MySql.Data.MySqlClient.MySqlException ex) {
                    MessageBox.Show(ex.Message);
                }
            }
        }
开发者ID:squilliams,项目名称:inventralalab,代码行数:32,代码来源:EditAlat.xaml.cs


示例19: LoadItems

        public static void LoadItems()
        {
            lock (DatabaseHandler.ConnectionLocker)
            {
                var sqlText = "SELECT * FROM datas_items";
                var sqlCommand = new MySqlCommand(sqlText, DatabaseHandler.Connection);

                var sqlReader = sqlCommand.ExecuteReader();

                while (sqlReader.Read())
                {
                    var item = new Models.Items.ItemModel();

                    item.ID = sqlReader.GetInt32("ID");
                    item.Pods = sqlReader.GetInt16("Weight");
                    item.Price = sqlReader.GetInt32("Price");
                    item.Type = sqlReader.GetInt16("Type");
                    item.Level = sqlReader.GetInt16("Level");
                    item.Jet = sqlReader.GetString("Stats");
                    item.Condistr = sqlReader.GetString("Conditions");

                    item.ParseWeaponInfos(sqlReader.GetString("WeaponInfo"));

                    item.ParseRandomJet();

                    lock(ItemsList)
                        ItemsList.Add(item);
                }

                sqlReader.Close();
            }

            Utilities.Loggers.StatusLogger.Write(string.Format("Loaded @'{0}' [email protected] from the database !", ItemsList.Count));
        }
开发者ID:T4NK,项目名称:SunDofus,代码行数:34,代码来源:ItemsCache.cs


示例20: LoadCharacters

 private static void LoadCharacters()
 {
     Utilities.ConsoleStyle.Infos("Loading @[email protected] ..");
     var query = new MySqlCommand("SELECT * FROM characters", DatabaseManager.Connection);
     var reader = query.ExecuteReader();
     while (reader.Read())
     {
         var character = new Models.Character()
         {
             ID = reader.GetInt32("id"),
             Account = reader.GetInt32("account"),
             Nickname = reader.GetString("nickname"),
             Level = reader.GetInt32("level"),
             Experience = reader.GetInt64("experience"),
             Sex = reader.GetInt32("sex"),
             Breed = reader.GetInt32("breed"),
             SkinColor = reader.GetInt32("skincolor"),
             HairColor = reader.GetInt32("haircolor"),
             PupilColor = reader.GetInt32("pupilcolor"),
             SkinColorFactor = reader.GetInt32("skincolorfactor"),
             HairColorFactor = reader.GetInt32("haircolorfactor"),
             Cloth = reader.GetInt32("cloth"),
             Face = reader.GetInt32("face"),
             Title = reader.GetInt32("title"),
         };
         Characters.Add(character);
     }
     reader.Close();
     Utilities.ConsoleStyle.Infos("Loaded @'" + Characters.Count + "'@ characters !");
 }
开发者ID:sirgebet,项目名称:WakSharp,代码行数:30,代码来源:Storage.cs



注:本文中的MySql.Data.MySqlClient.MySqlCommand类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# MySqlClient.MySqlCommandBuilder类代码示例发布时间:2022-05-26
下一篇:
C# Tests.testEntities类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap