当前位置: 首页>>代码示例>>C#>>正文


C# MySqlClient.MySqlCommand类代码示例

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


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

示例1: EditSptInfo

        private void EditSptInfo(SettingsData returnEditedsettingsData)
        {
            MySql.Data.MySqlClient.MySqlConnection msqlConnection = null;

            msqlConnection = new MySql.Data.MySqlClient.MySqlConnection("server=localhost;user id=root;Password=technicise;database=sptdb;persist security info=False");
            try
            {   //define the command reference
                MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand();
                msqlCommand.Connection = msqlConnection;

                msqlConnection.Open();
                int idSptinfo = 1;
                msqlCommand.CommandText = "UPDATE sptinfo SET name='" + returnEditedsettingsData.Name + "', address='" + returnEditedsettingsData.Address + "', phone='" +
                    returnEditedsettingsData.Phone + "', bill_disclaimer='" + returnEditedsettingsData.BillDisclaimer + "', invoice_prefix='" + returnEditedsettingsData.InvoicePrefix +
                    "' WHERE id_sptinfo='" + idSptinfo + "'; ";

                msqlCommand.ExecuteNonQuery();

            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message);
            }
            finally
            {
                //always close the connection
                msqlConnection.Close();
            }
        }
开发者ID:shuiping150,项目名称:SalesPurchaseTracker,代码行数:29,代码来源:SPTSettingsWindow.xaml.cs

示例2: FetchePassword

        public static string FetchePassword()
        {
            string passwordStr = string.Empty;

            MySql.Data.MySqlClient.MySqlConnection msqlConnection = null;

            msqlConnection = new MySql.Data.MySqlClient.MySqlConnection("server=localhost;user id=root;Password=technicise;database=sptdb;persist security info=False");
            try
            {   //define the command reference
                MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand();
                msqlCommand.Connection = msqlConnection;

                msqlConnection.Open();

                msqlCommand.CommandText = "Select password from sptinfo;";
                MySql.Data.MySqlClient.MySqlDataReader msqlReader = msqlCommand.ExecuteReader();

                msqlReader.Read();

                passwordStr = msqlReader.GetString("password");

            }
            catch (Exception er)
            {
                //Assert//.Show(er.Message);
            }
            finally
            {
                //always close the connection
                msqlConnection.Close();
            }

            return passwordStr;
        }
开发者ID:shuiping150,项目名称:SalesPurchaseTracker,代码行数:34,代码来源:FetchSPTSettings.cs

示例3: SqlScalar

            /// <summary>
            /// Для выполнения запросов к MySQL с возвращением 1 параметра.
            /// </summary>
            /// <param name="sql">Текст запроса к базе данных</param>
            /// <param name="connection">Строка подключения к базе данных</param>
            /// <returns>Возвращает значение при успешном выполнении запроса, текст ошибки - при ошибке.</returns>
            public static MyResult SqlScalar(string sql, string connection)
            {
                MyResult result = new MyResult();
                try
                {
                    MySql.Data.MySqlClient.MySqlConnection connRC = new MySql.Data.MySqlClient.MySqlConnection(connection);
                    MySql.Data.MySqlClient.MySqlCommand commRC = new MySql.Data.MySqlClient.MySqlCommand(sql, connRC);
                    connRC.Open();
                    try
                    {
                        result.ResultText = commRC.ExecuteScalar().ToString();
                        result.HasError = false;
                    }
                    catch (Exception ex)
                    {
                        result.ErrorText = ex.Message;
                        result.HasError = true;

                    }
                    connRC.Close();
                }
                catch (Exception ex)//Этот эксепшн на случай отсутствия соединения с сервером.
                {
                    result.ErrorText = ex.Message;
                    result.HasError = true;
                }
                return result;
            }
开发者ID:nebosvod,项目名称:notify,代码行数:34,代码来源:Main.cs

示例4: assignEstimator

        public static void assignEstimator(estimateInfo estimateToEdit)
        {
            MySql.Data.MySqlClient.MySqlConnection msqlConnection = OpenDbConnection();

            try
            {   //define the command reference
                MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand();
                msqlCommand.Connection = msqlConnection;

                msqlCommand.CommandText = "UPDATE estimate SET [email protected] WHERE [email protected]";

                msqlCommand.Parameters.AddWithValue("@estimator", estimateToEdit.estimator);
                msqlCommand.Parameters.AddWithValue("@appNo", estimateToEdit.appsNo);
                msqlCommand.ExecuteNonQuery();

            }
            catch (Exception er)
            {
            }
            finally
            {
                //always close the connection
                msqlConnection.Close();
            }
        }
开发者ID:sayan801,项目名称:ElectricSupplyCustomerManagmentSystem,代码行数:25,代码来源:DbInteraction.cs

示例5: ConnectInsertToDoListTable

        public static void ConnectInsertToDoListTable(ToDoData tdData)
        {
            //define the connection reference and initialize it
            MySql.Data.MySqlClient.MySqlConnection msqlConnection = OpenDbConnection();

            try
            {   //define the command reference
                MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand();
                msqlCommand.Connection = msqlConnection;

                msqlCommand.CommandText = "INSERT INTO to_do(date_time,to_do,id)" + "VALUES(@date_time,@to_do,@id)";

                msqlCommand.Parameters.AddWithValue("@date_time", tdData.date_time);
                msqlCommand.Parameters.AddWithValue("@to_do", tdData.to_do);
                msqlCommand.Parameters.AddWithValue("@id", tdData.id);

                msqlCommand.ExecuteNonQuery();

            }
            catch (Exception er)
            {
            }
            finally
            {
                //always close the connection
                msqlConnection.Close();
            }
        }
开发者ID:shuiping150,项目名称:SalesPurchaseTracker,代码行数:28,代码来源:DbInteraction.cs

示例6: assignDonor

        public static void assignDonor(PatientInfo patientData)
        {
            MySql.Data.MySqlClient.MySqlConnection msqlConnection = OpenDbConnection();

            try
            {   //define the command reference
                MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand();
                msqlCommand.Connection = msqlConnection;

                msqlCommand.CommandText = "UPDATE patient SET [email protected]_donor, assigned_donor_contact = @assigned_donor_contact WHERE [email protected]_id";
                msqlCommand.Parameters.AddWithValue("@patient_id", patientData.id);
                msqlCommand.Parameters.AddWithValue("@assigned_donor", patientData.assignedDonor);
                msqlCommand.Parameters.AddWithValue("@assigned_donor_contact", patientData.donorContact);
                msqlCommand.ExecuteNonQuery();

            }
            catch (Exception er)
            {
            }
            finally
            {
                //always close the connection
                msqlConnection.Close();
            }
        }
开发者ID:sayan801,项目名称:BloodDonationManagement,代码行数:25,代码来源:DbInteraction.cs

示例7: StateChanged_Executed

        void StateChanged_Executed(object sender, ExecutedEventArgs e)
        {
            string messgae = "불러오기를 완료하였습니다.";
            AMR_MST04Model model = new AMR_MST04Model();
            
            model = (AMR_MST04Model)e.Parameter;
            
            MySqlManage crud = new MySqlManage(ConfigurationManager.ConnectionStrings["MySQL"].ConnectionString);
            DataSet ds = new DataSet();
            MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand();

            cmd.CommandText = "CALL sp_load(@sno, @datefrom, @dateto);";
            cmd.Parameters.AddWithValue("@sno", model.MST04SNO);
            cmd.Parameters.AddWithValue("@datefrom", model.From.ToString("yyyy-MM-dd") + " 00");
            cmd.Parameters.AddWithValue("@dateto", model.To.ToString("yyyy-MM-dd") + " 00");

            ds = crud.CallSPMariaDBTable(crud.Connection, cmd);

            if (ds.Tables.Count > 0)
            {
                model.DataTable = ds.Tables[0];
                
                CurrentForm.SearchComplete(model);
            }
            CurrentForm.ShowMessage(messgae);
        }
开发者ID:shine8319,项目名称:DLS,代码行数:26,代码来源:G02I01ModulePresenter.cs

示例8: Register_AfterCheck

        public bool Register_AfterCheck(string Username, string Password, string Email, string FullName)
        {
            MySql.Data.MySqlClient.MySqlConnection con = null;
            Database.Configuration.open(ref con);

            string sql = @"
                INSERT INTO `users`(`level`, `state`, `username`, `email`, `password`, `realname`)
                VALUES (@level, @state, @username, @email, @password, @realname)";

            var defaultLevel = Util.Config.Get().GetInt32("registration_default_authlevel", 2);
            var defaultState = Util.Config.Get().GetInt32("registration_default_state",     0);

            using (var rdr = new MySql.Data.MySqlClient.MySqlCommand(sql, con)) {
                rdr.Parameters.AddWithValue("@level",       defaultLevel);
                rdr.Parameters.AddWithValue("@state",       defaultState);

                rdr.Parameters.AddWithValue("@username",    Username);
                rdr.Parameters.AddWithValue("@realname",    FullName);

                rdr.Parameters.AddWithValue("@email",       Email);
                rdr.Parameters.AddWithValue("@password",    Password);

                try {
                    rdr.ExecuteNonQuery(); // Let it throw a error so i can see if it works
                } catch(Exception ex) {
                    throw;
                    return false;
                }
            } con.Close();
            return true;
        }
开发者ID:CallumCarmicheal,项目名称:AspDashboard,代码行数:31,代码来源:Register.cs

示例9: GetForecastFromDatabase

        public CityForeCast[] GetForecastFromDatabase()
        {
            //SqlConnection connection = new SqlConnection(@"Data Source=(LocalDb)\MSSQLLocalDb;Initial Catalog=weatherForecast;Integrated Security=True;Pooling=False");
            MySql.Data.MySqlClient.MySqlConnection connection = new MySql.Data.MySqlClient.MySqlConnection(@"Server=eu-cdbr-azure-west-c.cloudapp.net;Database=BDMeteo;Uid=b95badd8e1dbad;Pwd=bde4c7b6;Pooling=True");
            connection.Open();
            MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand("SELECT * FROM tablemeteo", connection);
            MySql.Data.MySqlClient.MySqlDataReader reader = cmd.ExecuteReader();
            List<CityForeCast> forecasts = new List<CityForeCast>();
            while (reader.Read())
            {
                CityForeCast forecast = new CityForeCast();
                forecast.City = (string)reader["City"];
                forecast.description = (string)reader["Description"];
                forecast.MaxTemp = (decimal)reader["Temperature"];
                forecasts.Add(forecast);

            }
            reader.Close(); // Fermer le reader avant de fermer la connection
            connection.Close();
            return forecasts.ToArray();
            //var ctx = new weatherForecastEntities();
            //var forecast = ctx.Tables.Select(f => new CityForeCast()
            //{
            //    City = f.City,
            //    description = f.Description,
            //    MaxTemp = (decimal)f.Temperature
            //});
            //return forecast;
        }
开发者ID:Racuine,项目名称:MeteoApplication,代码行数:29,代码来源:dataAccess.cs

示例10: DeleteStock

        private void DeleteStock(string stockToDelete)
        {
            msqlConnection = new MySql.Data.MySqlClient.MySqlConnection("server=localhost;user id=root;Password=technicise;database=sptdb;persist security info=False");
            try
            {   //define the command reference
                MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand();
                msqlCommand.Connection = msqlConnection;

                msqlConnection.Open();

                msqlCommand.CommandText = "DELETE FROM stock WHERE id= @vendorIdToDelete";
                msqlCommand.Parameters.AddWithValue("@vendorIdToDelete", stockToDelete);

                MySql.Data.MySqlClient.MySqlDataReader msqlReader = msqlCommand.ExecuteReader();

            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message);
            }
            finally
            {
                //always close the connection
                msqlConnection.Close();
            }
        }
开发者ID:shuiping150,项目名称:SalesPurchaseTracker,代码行数:26,代码来源:StockManagerWindow.xaml.cs

示例11: ConnectInsertTocustomerPaymentTable

        public static void ConnectInsertTocustomerPaymentTable(CustomerPaymentData customerDataObject)
        {
            MySql.Data.MySqlClient.MySqlConnection msqlConnection = OpenDbConnection();

            try
            {
                //define the command reference
                MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand();

                //define the connection used by the command object
                msqlCommand.Connection = msqlConnection;

                FeedcustomerData(msqlCommand, customerDataObject);

            }
            catch (Exception er)
            {

            }
            finally
            {
                msqlConnection.Close();

            }
        }
开发者ID:shuiping150,项目名称:SalesPurchaseTracker,代码行数:25,代码来源:DbInteraction.cs

示例12: EditSptPassword

        public static void EditSptPassword(string passwordStr)
        {
            MySql.Data.MySqlClient.MySqlConnection msqlConnection = null;

            msqlConnection = new MySql.Data.MySqlClient.MySqlConnection("server=localhost;user id=root;Password=technicise;database=sptdb;persist security info=False");
            try
            {   //define the command reference
                MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand();
                msqlCommand.Connection = msqlConnection;

                msqlConnection.Open();
                int idSptinfo = 1;

                msqlCommand.CommandText = "UPDATE sptinfo SET password='" + passwordStr + "' WHERE id_sptinfo='" + idSptinfo + "'; ";
                msqlCommand.ExecuteNonQuery();
            }
            catch (Exception er)
            {
                //MessageBox.Show(er.Message);
            }
            finally
            {
                //always close the connection
                msqlConnection.Close();
            }
        }
开发者ID:shuiping150,项目名称:SalesPurchaseTracker,代码行数:26,代码来源:FetchSPTSettings.cs

示例13: AddAgent

        public bool AddAgent(string name, string surname, string phone, string email, string password)
        {
            DatabaseManager dbManager = new DatabaseManager();
            Cryptography crypto = new Cryptography();
            MySql.Data.MySqlClient.MySqlCommand com = new MySql.Data.MySqlClient.MySqlCommand();

            return (dbManager.NonReturnQuery("INSERT INTO Agent (Agent_Name , Agent_Surname, Agent_Phone, Agent_Email, Agent_Password) VALUES ('" + name + "','" + surname + "','" + phone + "','" + email + "','" + Cryptography.CreateHash(password).ToString() + "');"));
        }
开发者ID:gpdiemelkman,项目名称:REII422_DesktopApp,代码行数:8,代码来源:AgentManager.cs

示例14: buttonOK_Click

 private void buttonOK_Click(object sender, EventArgs e)
 {
     var conn = this.dataset.CreateSQLConnection();
     conn.Open();
     var query = new MySql.Data.MySqlClient.MySqlCommand(String.Format("call settlement('{0}')",dateTimePickerSettleDate.Value.ToString("yyyy-MM-dd")), conn);
     query.ExecuteNonQuery();
     this.Close();
 }
开发者ID:Dalizi,项目名称:otc_platform_new,代码行数:8,代码来源:FormSettlement.cs

示例15: Execute

 public static int Execute(string sql)
 {
     using (var conn = new MySql.Data.MySqlClient.MySqlConnection(ConnectString()))
     {
         conn.Open();
         var cmd = new MySql.Data.MySqlClient.MySqlCommand(sql, conn);
         int i = cmd.ExecuteNonQuery();
         conn.Close();
         return i;
     }
 }
开发者ID:gofixiao,项目名称:HYPDM_Pro,代码行数:11,代码来源:MySqlUtil.cs


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