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

C# MySqlClient.MySqlConnection类代码示例

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

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



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

示例1: 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


示例2: 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


示例3: 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


示例4: CreateStaff

 internal void CreateStaff(Staff staff)
 {
     using (MySqlConnection conn = new MySqlConnection(PredatorConstants.CONNECTION_STRING))
     {
         if (MySqlConnectionManager.OpenConnection(conn))
         {
             string commandText =
     @"INSERT INTO staff (fName, lName, username, password, email, accessLevel, creationDate)
     VALUES(@FNAME, @LNAME, @USERNAME, @PASSWORD, @EMAIL, @ACCESSLEVEL, @CREATIONDATE)";
             MySqlCommand command = new MySqlCommand(commandText, conn);
             command.Parameters.Add("@FNAME", MySqlDbType.VarChar); ;
             command.Parameters["@FNAME"].Value = staff.fName;
             command.Parameters.Add("@LNAME", MySqlDbType.VarChar);
             command.Parameters["@LNAME"].Value = staff.lName;
             command.Parameters.Add("@USERNAME", MySqlDbType.VarChar);
             command.Parameters["@USERNAME"].Value = staff.username;
             command.Parameters.Add("@PASSWORD", MySqlDbType.VarChar);
             command.Parameters["@PASSWORD"].Value = staff.password;
             command.Parameters.Add("@EMAIL", MySqlDbType.VarChar);
             command.Parameters["@EMAIL"].Value = staff.email;
             command.Parameters.Add("@ACCESSLEVEL", MySqlDbType.Int32);
             command.Parameters["@ACCESSLEVEL"].Value = staff.accessLevel;
             command.Parameters.Add("@CREATIONDATE", MySqlDbType.DateTime);
             command.Parameters["@CREATIONDATE"].Value = staff.creationDate;
             command.ExecuteNonQuery();
             MySqlConnectionManager.CloseConnection(conn);
         }
     }
 }
开发者ID:JSamp701,项目名称:Predator-Check-Management-System,代码行数:29,代码来源:StaffProvider.cs


示例5: mysqlVer

        public static void mysqlVer(MySqlConnection mySqlConnection)
        {
            MySqlCommand mySqlCommand = mySqlConnection.CreateCommand ();
            mySqlCommand.CommandText = "SELECT * FROM categoria";

            MySqlDataReader mySqlDataReader = mySqlCommand.ExecuteReader ();

            Console.WriteLine ("FieldCount = {0}", mySqlDataReader.FieldCount);
            for (int index = 0; index < mySqlDataReader.FieldCount; index++)
            {
                Console.WriteLine ("Column {0} = {1}", index, mySqlDataReader.GetName (index));

            }

            while (mySqlDataReader.Read())
            {
                object id = mySqlDataReader ["id"];
                object nombre = mySqlDataReader ["nombre"];

                Console.Write ("\n{0}, {1}", id, nombre);

            }

            Console.WriteLine ("\n\nPress any key to continue...");
            Console.Read ();

            mySqlDataReader.Close ();
        }
开发者ID:juankza,项目名称:ad,代码行数:28,代码来源:Program.cs


示例6: GetDBConnection

        public MySqlConnection GetDBConnection()
        {
            try
            {
                MySqlConnection db;
                if (_databaseQueue.Count > 0)
                {
                    db = _databaseQueue.Dequeue();
                    System.Threading.ThreadPool.QueueUserWorkItem(ProcessDatabaseQueue);
                }
                else
                {
                    db = new MySqlConnection(Config.GetConnectionString());
                    db.Open();
                }

                return db;
            }
            catch (MySqlException e)
            {
                MySqlConnection db = new MySqlConnection();
                Logger.WriteLog(e.Message, Logger.LogType.Error);
                db.Dispose();

                return db;
            }
        }
开发者ID:xNexus9,项目名称:tabula-rasa-server-emulator,代码行数:27,代码来源:DatabaseFactory.cs


示例7: GetConnection

        // CONNECTION POOLING IS A MUST!!!
        // TODO: Rewrite needed for config.xml, only providing username, password and database. Create connection string via stringbuilders
        /// <summary>
        /// </summary>
        /// <returns>
        /// </returns>
        /// <exception cref="Exception">
        /// </exception>
        public static IDbConnection GetConnection()
        {
            IDbConnection conn = null;
            if (Sqltype == "MySql")
            {
                conn = new MySqlConnection(ConnectionString_MySQL);
            }

            if (Sqltype == "MsSql")
            {
                conn = new SqlConnection(ConnectionString_MSSQL);
            }

            if (Sqltype == "PostgreSQL" )
            {
                conn = new NpgsqlConnection(ConnectionString_PostGreSQL);
            }

            if (conn == null)
            {
                throw new Exception("ConnectionString error");
            }

            conn.Open();
            return conn;
        }
开发者ID:Algorithman,项目名称:TestCellAO,代码行数:34,代码来源:Connector.cs


示例8: 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


示例9: ConnectDatabase

 private void ConnectDatabase()
 {
     string connStr = "server=" + caspar_database_server_hostname + ";database=" + caspar_database_server_database + ";uid=" +
         caspar_database_server_username + ";password=" + caspar_database_server_password + ";";
     connection = new MySqlConnection(connStr);
     connection.Open();
 }
开发者ID:zhouqilin,项目名称:CasparCGPlayout,代码行数:7,代码来源:Form1.cs


示例10: Main

        //m mayucula en main obligatoriamente.
        public static void Main(string[] args)
        {
            MySqlConnection mysqlconection = new MySqlConnection (
                "Database=dbprueba;Data Source=localhost;User id=root; Password=sistemas");

            mysqlconection.Open ();

            MySqlCommand mysqlcommand = mysqlconection.CreateCommand ();
            mysqlcommand.CommandText = "select * from articulo";
            //				"select a.categoria as articulocategoria, c.nombre as categorianombre, count(*)" +
            //				"from articulo a " +
            //				"left join categoria c on a.categoria= c.id " +
            //				"group by articulocategoria, categorianombre";

            MySqlDataReader mysqldatareader = mysqlcommand.ExecuteReader ();

            //---------------------------------------------------------------
            updateDatabase (mysqlconection);
            showColumnNames (mysqldatareader);
            show (mysqldatareader);

            //---------------------------------------------------------------
            mysqldatareader.Close ();
            mysqlconection.Close ();
        }
开发者ID:DiegoDeBelda,项目名称:AD,代码行数:26,代码来源:Program.cs


示例11: WykonajSelecta

        /// <summary>
        /// Wykonuje iSelecta na bazie, zwraca MySqlDataReader z wynikami
        /// </summary>
        /// <param name="iSelect">string z SELECTEM</param>
        /// <param name="iGetReaderData">Funkcja(MySqlDataReader), ogarniająca dane</param>
        public static void WykonajSelecta(string iSelect, Action<MySqlDataReader> iGetReaderData)
        {
            //MySqlDataReader readerToReturn;

            string MyConnectionString = "Server=localhost;Database=mydb1;Uid=root;";
            MySqlConnection con = new MySqlConnection(MyConnectionString);
            con.Open();

            try
            {
                MySqlCommand cmd = con.CreateCommand();
                cmd.CommandText = iSelect;
                MySqlDataReader reader = cmd.ExecuteReader();

                //Delegata, który ogarnie dane

                iGetReaderData(reader);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
            }
            //no i chuj, żeby zamknąć połączenie trzeba tutaj wjebać delegata
            //return readerToReturn;
        }
开发者ID:Wilczek770,项目名称:Przychodnia,代码行数:37,代码来源:TworzenieZapytan.cs


示例12: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                button5.Enabled = true;
                selectedItem = listBox1.SelectedItem.ToString();
                querry = "SELECT * FROM " + listBox1.SelectedItem.ToString();
                connection = new MySqlConnection(connectionString);
                dataAdapter = new MySqlDataAdapter(querry, connectionString);
                dt = new DataTable();
                dataAdapter.Fill(dt);
                if (dataGridView1.DataSource == null)
                {

                    dataGridView1.Rows.Clear();
                    dataGridView1.Columns.Clear();
                }
                dataGridView1.DataSource = dt;
            }
            catch (NullReferenceException ex)
            {
                MessageBox.Show("Please select one of the databases in the list.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error occured!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
开发者ID:Tarnacop,项目名称:Monthly-Stock-Planning,代码行数:28,代码来源:UserForm.cs


示例13: IsFullPublic

        public static bool IsFullPublic()
        {
            bool isPublic = false;
            bool isFullyPublic = false;

            using (MySqlConnection con = new MySqlConnection(Database.ConnectionString))
            {
                con.Open();

                using (MySqlCommand command = con.CreateCommand())
                {
                    command.Parameters.AddWithValue("@docID", requestID);
                    command.CommandText =
                        "SELECT public,publicPassword FROM documents WHERE docID = @docID";
                    MySqlDataReader r = command.ExecuteReader();
                    while(r.Read())
                    {
                        isPublic = Convert.ToBoolean(r["public"]);
                        if(isPublic && (r["publicPassword"].ToString() == "" || r["publicPassword"].ToString() == "public"))
                        {
                            isFullyPublic = true;
                        }
                    }

                }

            }
            return isFullyPublic;
        }
开发者ID:Greblak,项目名称:LiveDocs,代码行数:29,代码来源:ViewPublicDocument.aspx.cs


示例14: FetchPublicContent

        public static string FetchPublicContent(string password)
        {
            using (MySqlConnection con = new MySqlConnection(Database.ConnectionString))
            {
                con.Open();

                using (MySqlCommand command = con.CreateCommand())
                {
                    command.Parameters.AddWithValue("@docID", requestID);
                    command.Parameters.AddWithValue("@password", password);
                    command.CommandText =
                       "SELECT Revisions.Content from Revisions join Documents on Revisions.docID=Documents.docID where [email protected] and Revisions.revisionID=(Select Max(revisionID) from Revisions where [email protected]) AND publicPassword = @password" ;
                    MySqlDataReader reader = command.ExecuteReader();

                    if(reader.HasRows)
                    {
                        reader.Read();
                        return LiveDocs.livedocs.Editor.ParseMarkup((String)reader[0]);
                    }
                    else
                    {
                        throw new Exception("Password not correct or document does not exist");
                    }

                }

            }
            return null;
        }
开发者ID:Greblak,项目名称:LiveDocs,代码行数:29,代码来源:ViewPublicDocument.aspx.cs


示例15: AdaptadorABM

        private static MySqlDataAdapter AdaptadorABM(MySqlConnection SqlConnection1)
        {
            MySqlCommand SqlInsertCommand1;
            MySqlCommand SqlUpdateCommand1;
            MySqlCommand SqlDeleteCommand1;
            MySqlDataAdapter SqlDataAdapter1 = new MySqlDataAdapter();
            SqlInsertCommand1 = new MySqlCommand("Generos_Insertar", SqlConnection1);
            SqlUpdateCommand1 = new MySqlCommand("Generos_Actualizar", SqlConnection1);
            SqlDeleteCommand1 = new MySqlCommand("Generos_Borrar", SqlConnection1);
            SqlDataAdapter1.DeleteCommand = SqlDeleteCommand1;
            SqlDataAdapter1.InsertCommand = SqlInsertCommand1;
            SqlDataAdapter1.UpdateCommand = SqlUpdateCommand1;

            // IMPLEMENTACIÓN DE LA ORDEN UPDATE
            SqlUpdateCommand1.Parameters.Add("p_id", MySqlDbType.Int32, 3, "IdGeneroGEN");
            SqlUpdateCommand1.Parameters.Add("p_descripcion", MySqlDbType.VarChar, 50, "DescripcionGEN");
            SqlUpdateCommand1.Parameters.Add("p_activoWeb", MySqlDbType.Int32, 1, "ActivoWebGEN");
            SqlUpdateCommand1.CommandType = CommandType.StoredProcedure;

            // IMPLEMENTACIÓN DE LA ORDEN INSERT
            SqlInsertCommand1.Parameters.Add("p_id", MySqlDbType.Int32, 3, "IdGeneroGEN");
            SqlInsertCommand1.Parameters.Add("p_descripcion", MySqlDbType.VarChar, 50, "DescripcionGEN");
            SqlInsertCommand1.Parameters.Add("p_activoWeb", MySqlDbType.Int32, 1, "ActivoWebGEN");
            SqlInsertCommand1.CommandType = CommandType.StoredProcedure;

            // IMPLEMENTACIÓN DE LA ORDEN DELETE
            SqlDeleteCommand1.Parameters.Add("p_id", MySqlDbType.Int32, 3, "IdGeneroGEN");
            SqlDeleteCommand1.CommandType = CommandType.StoredProcedure;
            return SqlDataAdapter1;
        }
开发者ID:BenjaOtero,项目名称:trend-gestion-desktop,代码行数:30,代码来源:GenerosDAL.cs


示例16: 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


示例17: WypelnijGridView

        private void WypelnijGridView()
        {
            txtDruzyna.Text = "";
            txtImie.Text = "";
            txtNazwisko.Text = "";
            txtData.Text = "";
            txtPozycja.Text = "";
            txtWaga.Text = "";
            txtWzrost.Text = "";
            txtNumer.Text = "";

            string constr = ConfigurationManager.ConnectionStrings["pol"].ConnectionString;
            using (MySqlConnection con = new MySqlConnection(constr))
            {
                using (MySqlCommand cmd = new MySqlCommand("SELECT * FROM pilkarze"))
                {
                    using (MySqlDataAdapter sda = new MySqlDataAdapter())
                    {
                        cmd.Connection = con;
                        sda.SelectCommand = cmd;
                        using (DataTable dt = new DataTable())
                        {
                            sda.Fill(dt);
                            GridView1.DataSource = dt;
                            GridView1.DataBind();
                        }
                    }
                }
            }
        }
开发者ID:danielblokus,项目名称:Aplikacja-internetowa-technologia-ASP.NET,代码行数:30,代码来源:PilkarzeAdmin.aspx.cs


示例18: ObterCategoriasCadastradas

        public List<Categoria> ObterCategoriasCadastradas(string idioma)
        {
            List<Categoria> lista = new List<Categoria>();

            MySqlConnection conn = new MySqlConnection(connectionString);
            MySqlCommand cmd = new MySqlCommand();
            cmd.Connection = conn;
            cmd.CommandText = "SELECT id, nome, urlImagem FROM tb_categorias order by nome";

            conn.Open();
            MySqlDataReader dr = cmd.ExecuteReader();

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    lista.Add(new Categoria
                    {
                        id = (int)dr["id"],
                        nome = Tradutor.Traduzir(dr["nome"].ToString(), idioma),
                        urlImagem = dr["urlImagem"].ToString()
                    });
                }
            }
            conn.Close();

            return lista;
        }
开发者ID:JulioSI,项目名称:TP_Carefour,代码行数:28,代码来源:CategoriaDAO.cs


示例19: ManagerGeneralItemStagesGui

        /// <summary>
        /// Initializes a new instance of the <see cref="ManagerGeneralItemStagesGui"/> class.
        /// </summary>
        /// <param name="itemid">The itemid.</param>
        public ManagerGeneralItemStagesGui(string itemid)
        {
            //Login.close = 1;
            InitializeComponent();
            this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            this.itemID = itemid;
            try
            {
                MySqlConnection MySqlConn = new MySqlConnection(Login.Connectionstring);
                MySqlConn.Open();
                string Query1 = "select itemName from item where itemid='" + itemID + "'";
                MySqlCommand MSQLcrcommand1 = new MySqlCommand(Query1, MySqlConn);
                MSQLcrcommand1.ExecuteNonQuery();
                MySqlDataAdapter mysqlDAdp = new MySqlDataAdapter(MSQLcrcommand1);
                MySqlDataReader dr = MSQLcrcommand1.ExecuteReader();

                while (dr.Read())
                {
                    if (!dr.IsDBNull(0))
                    {
                        itemName = dr.GetString(0);
                    }

                }
                MySqlConn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            type_comboBox.Items.Add("רישום");
            type_comboBox.Items.Add("בעבודה");
            type_comboBox.Items.Add("תיקון");
            type_comboBox.Items.Add("פסול");
            type_comboBox.Items.Add("גמר ייצור");
            type_comboBox.Items.Add("הסתיים");
            type_comboBox.SelectedIndex = 0;
            itemidlabel.Content = itemID;
            itemnamelabel.Content = itemName;

            try
            {
                MySqlConnection MySqlConn = new MySqlConnection(Login.Connectionstring);
                MySqlConn.Open();
                string Query1 = ("SELECT itemStageOrder as `מספר שלב`,stageName as `שם שלב` ,stage_discription as `תאור השלב`  FROM item WHERE itemid='" + itemID + "'  and itemStatus='רישום' ");
                MySqlCommand MSQLcrcommand1 = new MySqlCommand(Query1, MySqlConn);
                MSQLcrcommand1.ExecuteNonQuery();
                MySqlDataAdapter mysqlDAdp = new MySqlDataAdapter(MSQLcrcommand1);
                dt.Clear();
                mysqlDAdp.Fill(dt);
                dataGrid1.ItemsSource = dt.DefaultView;
                mysqlDAdp.Update(dt);
                MySqlConn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
开发者ID:rogue452,项目名称:Karwasser,代码行数:64,代码来源:ManagerGeneralItemStagesGui.xaml.cs


示例20: 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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# MySqlClient.MySqlConnectionStringBuilder类代码示例发布时间:2022-05-26
下一篇:
C# MySqlClient.MySqlCommandBuilder类代码示例发布时间: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