Beispiel #1
0
        }//update_Empresa

        public int delete_Empresa(Clientes_Model cliente)
        {
            //Abre conecção
            using (MySqlCommand comando = new MySqlCommand(
                       "DELETE FROM clientes WHERE cod = @cod;", conexao))
            {
                try
                {
                    conexao.Open();
                    if (conexao.State == ConnectionState.Open)
                    {
                        //Se estiver aberta insere os dados na BD
                        // comando.Parameters.AddWithValue("@Nome", nome.Text);// para sql usar .Parameters.Add
                        comando.Parameters.AddWithValue("@cod", Convert.ToInt64(cliente.cod));
                        comando.BeginExecuteNonQuery();
                    }
                    this.status = 0;
                    this.conexao.Close();
                }
                catch (Exception Erro)
                {
                    this.status = 1;
                    this.conexao.Close();
                    MessageBox.Show("Impossível estabelecer conexão:" + Erro);
                }
            }
            return(this.status);
        } //delete_Empresa
Beispiel #2
0
        }//update_user

        public int delete_user(Usuarios_Model user)
        {
            //Abre conecção
            using (MySqlCommand comando = new MySqlCommand(
                       "DELETE FROM usuarios " +
                       "WHERE chave = @Chave AND  usuario = @Email; ", conexao))
            {
                try
                {
                    conexao.Open();
                    if (conexao.State == ConnectionState.Open)
                    {
                        //Se estiver aberta insere os dados na BD
                        // comando.Parameters.AddWithValue("@Nome", nome.Text);// para sql usar .Parameters.Add
                        comando.Parameters.AddWithValue("@Email", user.login);
                        comando.Parameters.AddWithValue("@Chave", user.chave);
                        comando.BeginExecuteNonQuery();
                    }
                    status = 0;
                    conexao.Close();
                }
                catch (Exception Erro)
                {
                    status = 1;
                    conexao.Close();
                    MessageBox.Show("Impossível estabelecer conexão:" + Erro);
                }
            }
            return(this.status);
        }//delete_user
        protected void ExecuteQuery(string query, MySqlConnection c)
        {
            MySqlCommand cmd = new MySqlCommand(query, c);

            cmd.BeginExecuteNonQuery();
            cmd.Dispose();
        }
Beispiel #4
0
        public static void AgregarCliente()
        {
            Console.Clear();
            try
            {
                Console.WriteLine("Nombre del Cliente");
                string nombre = Console.ReadLine();
                Console.WriteLine("Direccion: ");
                string direccion = Console.ReadLine();
                Console.WriteLine("Correo");
                string coreo = Console.ReadLine();

                int CantidadFacturas = 0;


                MySqlCommand insertar = new MySqlCommand(string.Format("insert into Clientes (nombreCliente,direccion,correo,cantidadFacuras) values ('{0}','{1}','{2}',{3})", nombre, direccion, coreo, CantidadFacturas), connection.conectar());

                insertar.BeginExecuteNonQuery();
                Console.Clear();
                Console.WriteLine("Agregar otro cliente? \n 1-Si \n 2-No");
                int resp = int.Parse(Console.ReadLine());

                if (resp == 1)
                {
                    Console.Clear();
                    AgregarCliente();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                AgregarCliente();
            }
        }
Beispiel #5
0
        public void FLUSH_PRIVILEGES(MySqlConnection LigacaoDB)
        {
            MySqlCommand CMD_FLUSH = new MySqlCommand();

            string QRY_FLUSH_PRIVILEGES = "FLUSH PRIVILEGES;";

            CMD_FLUSH.Connection  = LigacaoDB;
            CMD_FLUSH.CommandText = QRY_FLUSH_PRIVILEGES;

            try
            {
                IAsyncResult Working = CMD_FLUSH.BeginExecuteNonQuery(null, null);

                while (!Working.IsCompleted)
                {
                    // Accções Adicionais
                }

                CMD_FLUSH.EndExecuteNonQuery(Working);
            }

            catch
            {
                throw;
            }
        }
Beispiel #6
0
        /// <summary>
        /// 异步执行
        /// </summary>
        public static void CommandAsyn()
        {
            MySqlConnectionStringBuilder mySqlConnectionStringBuilder = new MySqlConnectionStringBuilder();

            //服务器地址
            mySqlConnectionStringBuilder.Server = "localhost";
            //端口号
            mySqlConnectionStringBuilder.Port = 3306;
            //指定数据库
            mySqlConnectionStringBuilder.Database = "test";
            //用户名
            mySqlConnectionStringBuilder.UserID = "root";
            //密码
            mySqlConnectionStringBuilder.Password = "******";
            using (MySqlConnection sqlConnection = new MySqlConnection(mySqlConnectionStringBuilder.ConnectionString)) {
                //sql语句
                string       sql          = "update tb_selcustomer set id=2";
                MySqlCommand mySqlCommand = new MySqlCommand(sql, sqlConnection);
                IAsyncResult asyncResult  = mySqlCommand.BeginExecuteNonQuery();
                //用于计时的变量
                double time = 0;
                //是否结束
                while (asyncResult.IsCompleted == false)
                {
                    time++;
                    Console.WriteLine("{0}s", time * 0.001);
                }
                if (asyncResult.IsCompleted == true)
                {
                    Console.WriteLine("共用时{0}s", time * 0.001);
                }
            }
        }
Beispiel #7
0
        public void CREATE_DB_USER(string Username, int Rank)
        {
            try
            {
                MySqlCommand CMD_CREATE_USER = new MySqlCommand("site_tvtuga_app_admin_users._SP_INSERT_AdminUsers", LigacaoDB.CONNECTION);
                CMD_CREATE_USER.CommandType = CommandType.StoredProcedure;

                CMD_CREATE_USER.Parameters.AddWithValue("_username", Username);
                CMD_CREATE_USER.Parameters.AddWithValue("_rank", Rank);

                LigacaoDB.OPEN_CONNECTION();

                CMD_CREATE_USER.Prepare();

                IAsyncResult Working_CreateUser = CMD_CREATE_USER.BeginExecuteNonQuery(null, null);

                //while (!Working_CreateUser.IsCompleted)
                //{
                // Accções Adicionais
                //}

                CMD_CREATE_USER.EndExecuteNonQuery(Working_CreateUser);
            }

            catch (Exception EX)
            {
                MessageBox.Show("Ocorreu um erro. Descrição do erro: \n\n " + EX.Message + "", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            finally
            {
                LigacaoDB.CLOSE_CONNECTION();
            }
        }
Beispiel #8
0
        public void AsyncInsert(string table, Dictionary <string, object> values)
        {
            if (values.Count <= 0)
            {
                throw new Exception("Please provide atleast some data to insert.");
            }

            string query        = string.Concat("INSERT INTO ", table, "(", string.Join(",", values.Keys), ") VALUES ");
            string valuesString = string.Empty;

            if (values.Count > 0)
            {
                foreach (KeyValuePair <string, object> entry in values)
                {
                    valuesString = string.Concat(valuesString, "@", entry.Key, ",");
                }
                query = string.Concat(query, "(", valuesString.Remove(valuesString.Length - 1), ")");
            }

            try {
                MySqlCommand cmd = new MySqlCommand(query, this.connection);

                foreach (KeyValuePair <string, object> entry in values)
                {
                    cmd.Parameters.AddWithValue("@" + entry.Key, entry.Value);
                }

                cmd.BeginExecuteNonQuery(new AsyncCallback(AsyncInsertCallback), cmd);
            } catch { }
        }
Beispiel #9
0
        public void CREATE_TYPE(string Tipo)
        {
            try
            {
                MySqlCommand CMD_CREATE_TYPE = new MySqlCommand("site_tvtuga_app_admin_users._SP_INSERT_WebsiteTipo", LigacaoDB);
                CMD_CREATE_TYPE.CommandType = CommandType.StoredProcedure;

                CMD_CREATE_TYPE.Parameters.AddWithValue("_nome", Tipo);

                LigacaoDB.Open();

                CMD_CREATE_TYPE.Prepare();

                IAsyncResult Working_CreateType = CMD_CREATE_TYPE.BeginExecuteNonQuery(null, null);

                CMD_CREATE_TYPE.EndExecuteNonQuery(Working_CreateType);
            }

            catch (Exception EX)
            {
                MessageBox.Show("Ocorreu um erro. Descrição do erro: \n\n " + EX.Message + "", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            finally
            {
                LigacaoDB.Close();
            }
        }
        private void _RunCommandAsynchronously(string query)
        {
            try
            {
                int count = 0;
                _commandExecutor = new MySqlCommand(query, _connectionHandle);

                IAsyncResult result = _commandExecutor.BeginExecuteNonQuery();
                while (!result.IsCompleted)
                {
                    Console.WriteLine("Waiting ({0})", count++);
                    System.Threading.Thread.Sleep(500);
                }
                Console.WriteLine("Command complete. Affected {0} rows.",
                                  _commandExecutor.EndExecuteNonQuery(result));
            }
            catch (SqlException ex)
            {
                Console.WriteLine("Error ({0}): {1}", ex.Number, ex.Message);
            }
            catch (InvalidOperationException ex)
            {
                Console.WriteLine("Error: {0}", ex.Message);
            }
            catch (Exception ex)
            {
                // You might want to pass these errors
                // back out to the caller.
                Console.WriteLine("Error: {0}", ex.Message);
            }
        }
Beispiel #11
0
        public void runsqlcmd(string sqlcmd)
        {
            var    serverName   = "127.0.0.1";
            var    uidName      = "root";
            var    pwdName      = "1234";
            var    databaseName = "BDS";
            string connStr      = String.Format("server={0};uid={1};pwd={2};database={3}",
                                                serverName, uidName, pwdName, databaseName);

            conn = new MySqlConnection(connStr);
            try
            {
                conn.Open();
                cmd = new MySqlCommand(sqlcmd, conn);
                cmd.ExecuteNonQuery();

                asyncResult = cmd.BeginExecuteNonQuery();
                nextTime    = 5;
                //timer1.Enabled = true;
                start = DateTime.Now;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception: " + ex.Message);
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
            }
        }
Beispiel #12
0
        //public IAsyncResult SpBeginExecuteNonQuery(string spName, AsyncCallback callback, object stateObject, string[] parameters, params object[] values) {
        //    throw new NotImplementedException();
        //}

        //public int SpEndExecuteNonQuery(IDbCommand cmd, IAsyncResult ar) {
        //    throw new NotImplementedException();
        //}

        public void SpBeginExecuteNonQuery(string spName, Action <AsyncDbCallback <int> > callback, string[] parameters, params object[] values)
        {
            if (callback == null)
            {
                throw new ArgumentNullException(string.Format("Exec {0} Error! Callback action can not be null!!", spName));
            }

            MySqlConnection cnn = GetConnection();
            MySqlCommand    cmd = new MySqlCommand(spName, cnn);

            cmd.CommandTimeout = CommandTimeout;
            cmd.CommandType    = CommandType.StoredProcedure;

            try {
                SpFillParameters(cmd, parameters, values);

                AsyncDbCallback <int> context = new AsyncDbCallback <int>();
                context.CallbackType  = CallbackType.NonQuery;
                context.DbType        = IICDbType.Mysql;
                context.SqlConnection = cnn;
                context.SqlCommand    = cmd;

                cmd.BeginExecuteNonQuery(new AsyncCallback(delegate(IAsyncResult ar) {
                    context.ar = ar;
                    callback(context);
                }), context);
            } catch (System.Exception ex) {
                cnn.Close();
                throw ex;
            }
        }
Beispiel #13
0
        public void ExecuteNonQuery()
        {
            if (Version < new Version(5, 0))
            {
                return;
            }

            execSQL("CREATE TABLE test (id int)");
            execSQL("CREATE PROCEDURE spTest() BEGIN SET @x=0; REPEAT INSERT INTO test VALUES(@x); " +
                    "SET @x=@x+1; UNTIL @x = 300 END REPEAT; END");

            MySqlCommand proc = new MySqlCommand("spTest", conn);

            proc.CommandType = CommandType.StoredProcedure;
            IAsyncResult iar   = proc.BeginExecuteNonQuery();
            int          count = 0;

            while (!iar.IsCompleted)
            {
                count++;
                System.Threading.Thread.Sleep(20);
            }
            proc.EndExecuteNonQuery(iar);
            Assert.IsTrue(count > 0);

            proc.CommandType = CommandType.Text;
            proc.CommandText = "SELECT COUNT(*) FROM test";
            object cnt = proc.ExecuteScalar();

            Assert.AreEqual(300, cnt);
        }
 public void AddUpdateVictimAccount(CSteamID id, decimal bounty, string lastDisplayName)
 {
     try
     {
         MySqlConnection connection = CreateConnection();
         MySqlCommand    command    = connection.CreateCommand();
         if (CheckExists(id))
         {
             command.CommandText = "UPDATE `" + FeexHitman.Instance.Configuration.Instance.FeexHitmanDatabase.DatabaseTableName + "` SET `bounty` = bounty + (" + bounty + "), `lastDisplayName` = @lastDisplayName, `lastUpdated` = NOW() WHERE `steamId` = '" + id.ToString() + "';";
         }
         else
         {
             command.CommandText = "INSERT IGNORE INTO `" + FeexHitman.Instance.Configuration.Instance.FeexHitmanDatabase.DatabaseTableName + "` (steamId,bounty,lastDisplayName,lastUpdated) VALUES('" + id.ToString() + "','" + bounty + "',@lastDisplayName,NOW());";
         }
         command.Parameters.AddWithValue("@lastDisplayName", lastDisplayName);
         connection.Open();
         IAsyncResult result = command.BeginExecuteNonQuery();
         command.EndExecuteNonQuery(result);
         connection.Close();
     }
     catch (Exception ex)
     {
         Logger.LogException(ex);
     }
 }
Beispiel #15
0
 public void AsyncQuery(string query)
 {
     try {
         MySqlCommand cmd = new MySqlCommand(query, this.connection);
         cmd.BeginExecuteNonQuery(new AsyncCallback(AsyncQueryCallback), cmd);
     } catch { }
 }
Beispiel #16
0
        public static List <Cliente> NuevoCliente()
        {
            //Cuando se conecte a la base de datos debe insertar las repuestas

            List <Cliente> clientes = Cliente.PreCargarClientes();

            Console.WriteLine("Nombre del Cliente");
            string nombre = Console.ReadLine();

            Console.WriteLine("Direccion: ");
            string direccion = Console.ReadLine();

            Console.WriteLine("Correo");
            string coreo = Console.ReadLine();

            int CantidadFacturas = 0;

            Cliente unNuevoCliente = new Cliente()
            {
                NombreCliente      = nombre,
                Direccion          = direccion,
                Correo             = coreo,
                CantidadDeFacturas = CantidadFacturas
            };

            clientes.Add(unNuevoCliente);

            MySqlCommand insertar = new MySqlCommand(string.Format("insert into Clientes (nombreCliente,direccion,correo,cantidadFacuras) values ('{0}','{1}','{2}',{3})", nombre, direccion, coreo, CantidadFacturas), connection.conectar());

            insertar.BeginExecuteNonQuery();
            return(clientes);
        }
Beispiel #17
0
        private void BtnHapus_Click(object sender, EventArgs e)
        {
            string query = "DELETE FROM kurir WHERE no_ktp = @no_ktp";

            try
            {
                databaseConnection.Open();

                MySqlCommand cmd = new MySqlCommand(query, databaseConnection);
                cmd.CommandTimeout = 60;
                cmd.Parameters.AddWithValue("@no_ktp", tbNoKTP.Text);

                cmd.BeginExecuteNonQuery();
                MessageBox.Show("Data berhasil dihapus");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                databaseConnection.Close();
            }
            refresh();
        }
        public void ExecuteNonQuery()
        {
            if (Version < new Version(5, 0)) return;

            execSQL("CREATE TABLE test (id int)");
            execSQL("CREATE PROCEDURE spTest() BEGIN SET @x=0; REPEAT INSERT INTO test VALUES(@x); " +
                "SET @x=@x+1; UNTIL @x = 300 END REPEAT; END");

            MySqlCommand proc = new MySqlCommand("spTest", conn);
            proc.CommandType = CommandType.StoredProcedure;
            IAsyncResult iar = proc.BeginExecuteNonQuery();
            int count = 0;
            while (!iar.IsCompleted)
            {
                count++;
                System.Threading.Thread.Sleep(20);
            }
            proc.EndExecuteNonQuery(iar);
            Assert.IsTrue(count > 0);

            proc.CommandType = CommandType.Text;
            proc.CommandText = "SELECT COUNT(*) FROM test";
            object cnt = proc.ExecuteScalar();
            Assert.AreEqual(300, cnt);
        }
Beispiel #19
0
        public ActionResult creatUser(FairOrderingSystem.Models.Company comp)
        {
            if (ModelState.IsValid)
            {
                string company  = comp.companyName;
                string Cell     = comp.cell;
                string Phone    = comp.phone;
                string Password = comp.password;
                string Email    = comp.email;

                string connectionString =
                    "Server=localhost;" +
                    "Database=fair;" +
                    "User ID=shane;" +
                    "Password=Gaming12;" +
                    "Pooling=false";
                string          sqlCommand = "INSERT INTO COMPANIES VALUES ('" + company + "','" + Cell + "','" + Phone + "','" + Password + "',NULL,'" + Email + "');";
                MySqlConnection conn       = new MySqlConnection(connectionString);
                conn.Open();
                MySqlCommand comm = conn.CreateCommand();
                comm.CommandText = sqlCommand;
                comm.BeginExecuteNonQuery();
                return(View());
            }

            return(View("NewUser"));
        }
Beispiel #20
0
        public void CREATE_WEBSITE(string Nome, string Endereco, string Tipo)
        {
            try
            {
                GET_TYPE_ID(Tipo);

                MySqlCommand CMD_CREATE_WEBSITE = new MySqlCommand("site_tvtuga_app_admin_users._SP_INSERT_Websites", LigacaoDB);
                CMD_CREATE_WEBSITE.CommandType = CommandType.StoredProcedure;

                CMD_CREATE_WEBSITE.Parameters.AddWithValue("_nome", Nome);
                CMD_CREATE_WEBSITE.Parameters.AddWithValue("_endereco", Endereco);
                CMD_CREATE_WEBSITE.Parameters.AddWithValue("_tipo", TYPE_ID);

                if (LigacaoDB.State == ConnectionState.Closed)
                {
                    LigacaoDB.Open();
                }

                CMD_CREATE_WEBSITE.Prepare();

                IAsyncResult Working_CreateWebsite = CMD_CREATE_WEBSITE.BeginExecuteNonQuery(null, null);

                CMD_CREATE_WEBSITE.EndExecuteNonQuery(Working_CreateWebsite);
            }

            catch (Exception EX)
            {
                MessageBox.Show("Ocorreu um erro. Descrição do erro: \n\n " + EX.Message + "", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            finally
            {
                LigacaoDB.Close();
            }
        }
        private void nonQueryGo_Click(object sender, System.EventArgs e)
        {
            string connStr = String.Format("server={0};uid={1};pwd={2};database={3}",
                                           server.Text, uid.Text, pwd.Text, database.Text);

            conn = new MySqlConnection(connStr);
            try
            {
                conn.Open();

                string sql = "DROP TABLE IF EXISTS AsyncSampleTable; CREATE TABLE AsyncSampleTable (numVal int)";
                cmd = new MySqlCommand(sql, conn);
                cmd.ExecuteNonQuery();

                sql = "DROP PROCEDURE IF EXISTS AsyncSample;" +
                      "CREATE PROCEDURE AsyncSample() BEGIN " +
                      "set @x=0; repeat set @x=@x+1; until @x > 5000000 end repeat; " +
                      "INSERT INTO AsyncSampleTable VALUES (1); end;";
                cmd.CommandText = sql;
                cmd.ExecuteNonQuery();

                cmd.CommandText = "AsyncSample";
                cmd.CommandType = CommandType.StoredProcedure;

                asyncResult    = cmd.BeginExecuteNonQuery();
                nextTime       = 5;
                timer1.Enabled = true;
                start          = DateTime.Now;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception: " + ex.Message);
            }
        }
        /// <summary>
        /// Creates an account in the DB.
        /// </summary>
        /// <param name="AccountName">The accountname.</param>
        /// <param name="Password">The password.</param>
        public static void CreateAccount(string AccountName, string Password)
        {
            MySqlCommand Command = new MySqlCommand("INSERT INTO Accounts(AccountName, Password) VALUES('" +
                                                    AccountName + "', '" + Password + "')");

            Command.BeginExecuteNonQuery(new AsyncCallback(EndCreateAccount), Command);
        }
Beispiel #23
0
        public void DELETE_DB_USER(int UserID)
        {
            try
            {
                // REMOVER ADMIN
                MySqlCommand CMD_DELETE_ADMIN = new MySqlCommand("site_tvtuga_app_admin_users._SP_DELETE_AdminUsers", LigacaoDB.CONNECTION);
                CMD_DELETE_ADMIN.CommandType = CommandType.StoredProcedure;
                CMD_DELETE_ADMIN.Parameters.AddWithValue("_id", UserID);

                // REMOVER ADMIN CONFIG
                MySqlCommand CMD_DELETE_ADMIN_CONFIG = new MySqlCommand("site_tvtuga_app_admin_users._SP_DELETE_AdminConfig", LigacaoDB.CONNECTION);
                CMD_DELETE_ADMIN_CONFIG.CommandType = CommandType.StoredProcedure;
                CMD_DELETE_ADMIN_CONFIG.Parameters.AddWithValue("_id", UserID);


                // REMOVER ADMIN SQL
                MySqlCommand CMD_DELETE_ADMIN_SQL = new MySqlCommand("site_tvtuga_app_admin_users._SP_DELETE_SQLUsers", LigacaoDB.CONNECTION);
                CMD_DELETE_ADMIN_SQL.CommandType = CommandType.StoredProcedure;
                CMD_DELETE_ADMIN_SQL.Parameters.AddWithValue("_id", UserID);

                LigacaoDB.OPEN_CONNECTION();

                CMD_DELETE_ADMIN.Prepare();
                CMD_DELETE_ADMIN_CONFIG.Prepare();
                CMD_DELETE_ADMIN_SQL.Prepare();

                IAsyncResult Working_DeleteAdminSQL = CMD_DELETE_ADMIN_SQL.BeginExecuteNonQuery(null, null);
                CMD_DELETE_ADMIN_SQL.EndExecuteNonQuery(Working_DeleteAdminSQL);

                IAsyncResult Working_DeleteAdminConfig = CMD_DELETE_ADMIN_CONFIG.BeginExecuteNonQuery(null, null);
                CMD_DELETE_ADMIN_CONFIG.EndExecuteNonQuery(Working_DeleteAdminConfig);

                IAsyncResult Working_DeleteAdmin = CMD_DELETE_ADMIN.BeginExecuteNonQuery(null, null);
                CMD_DELETE_ADMIN.EndExecuteNonQuery(Working_DeleteAdmin);

                using (RegistryKey Chave = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\Roaming\OptionsConfig\AppUsers", true))
                {
                    foreach (string User in Chave.GetValueNames())
                    {
                        if (User.Substring(2) == LISTVIEW_CONTAS.SelectedItems[0].Text)
                        {
                            Chave.DeleteValue(User);

                            Chave.SetValue(User, "");
                        }
                    }
                }
            }

            catch (Exception EX)
            {
                MessageBox.Show("Ocorreu um erro. Descrição do erro: \n\n " + EX.Message + "", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            finally
            {
                LigacaoDB.CLOSE_CONNECTION();
            }
        }
 public void inserir(string nome, string pessoa, string cnpj)
 {
     if (bdConn.State == ConnectionState.Open)
     {
         MySqlCommand commS = new MySqlCommand("INSERT INTO consumidores VALUES(nome,pessoa,cnpj);", bdConn);
         commS.BeginExecuteNonQuery();
     }
 }
 public void inserir(string codigo, string leituraAtual, string leituraAnterior, string num)
 {
     if (bdConn.State == ConnectionState.Open)
     {
         MySqlCommand commS = new MySqlCommand("INSERT INTO consumidores VALUES(cpf,'0000000000','Leonardo');", bdConn);
         commS.BeginExecuteNonQuery();
     }
 }
Beispiel #26
0
        public void creerNouvelleUtilisateur(string taux)
        {
            MySqlCommand cmd = this.connection.CreateCommand();

            cmd.CommandText = "INSERT INTO users(taux) VALUES (@taux)";
            cmd.Parameters.AddWithValue("@taux", taux);
            cmd.BeginExecuteNonQuery();
        }
Beispiel #27
0
        public static void GuardarDetalle(List <DetalleFactura> df)
        {
            foreach (var i in df)
            {
                MySqlCommand insertar = new MySqlCommand(string.Format("insert into DetalleFactura (numeroFactura,nombreProducto,cantidadVendida,precioProducto) values('{0}','{1}',{2},{3}); ", i.NumeroFactura, i.NombreProducto, i.CantidadDelProducto, i.Precio), connection.conectar());

                insertar.BeginExecuteNonQuery();
            }
        }
Beispiel #28
0
        public static void GuardarFactura(Factura facturas)
        {
            string       user     = facturas.UsuarioQueLaGenero;
            string       cliente  = facturas.NombreCliente;
            double       monto    = facturas.Monto;
            MySqlCommand insertar = new MySqlCommand(string.Format("insert into Facturas (usuariQueLaGenero,cliente,Monto) values('{0}','{1}',{2}); ", user, cliente, monto), connection.conectar());

            insertar.BeginExecuteNonQuery();
        }
Beispiel #29
0
 public void AsyncQuery(string query)
 {
     try
     {
         MySqlCommand cmd = new MySqlCommand(query, OpenConnection());
         cmd.BeginExecuteNonQuery(AsyncQueryCallback, cmd);
     }
     catch { }
 }
        public void UPDATE_USER(MySqlConnection LigacaoDB, string ID, string Username, string Password)
        {
            //MySqlCommand CMD_UPDATE_USER = new MySqlCommand("SP_UPDATE_UTILIZADOR", LigacaoDB);
            //CMD_UPDATE_USER.CommandType = CommandType.StoredProcedure;

            //CMD_UPDATE_USER.Parameters.AddWithValue("_username", ID);
            //CMD_UPDATE_USER.Parameters.AddWithValue("_newname", Username);
            //CMD_UPDATE_USER.Parameters.AddWithValue("_password", Password);

            MySqlCommand CMD_UPDATE_USER = new MySqlCommand();

            CMD_UPDATE_USER.Connection  = LigacaoDB;
            CMD_UPDATE_USER.CommandText = "RENAME USER '" + ID + "'@'%' TO '" + Username + "'@'%';";

            MySqlCommand CMD_UPDATE_PASS = new MySqlCommand();

            CMD_UPDATE_PASS.Connection  = LigacaoDB;
            CMD_UPDATE_PASS.CommandText = "SET PASSWORD FOR '" + Username + "'@'%' = PASSWORD('" + Password + "');";

            LigacaoDB.Open();

            CMD_UPDATE_USER.Prepare();

            try
            {
                IAsyncResult Working_UpdateUser = CMD_UPDATE_USER.BeginExecuteNonQuery(null, null);

                while (!Working_UpdateUser.IsCompleted)
                {
                    // Accções Adicionais
                }

                CMD_UPDATE_USER.EndExecuteNonQuery(Working_UpdateUser);

                FuncoesDB.FLUSH_PRIVILEGES(LigacaoDB);

                IAsyncResult Working_UpdatePass = CMD_UPDATE_PASS.BeginExecuteNonQuery(null, null);

                while (!Working_UpdatePass.IsCompleted)
                {
                    // Accções Adicionais
                }

                CMD_UPDATE_PASS.EndExecuteNonQuery(Working_UpdatePass);

                FuncoesDB.FLUSH_PRIVILEGES(LigacaoDB);
            }

            catch
            {
                throw;
            }
            finally
            {
                LigacaoDB.Close();
            }
        }
Beispiel #31
0
        public MysqlConnection()
        {
            MySqlConnection bdConn = new MySqlConnection("server=localhost;database=TEST;uid=root");

            bdConn.Open();

            MySqlCommand commS = new MySqlCommand("INSERT INTO PAH VALUES('teste1')", bdConn);

            commS.BeginExecuteNonQuery();
        }