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


C# DBHelper.ExecuteNonQuery方法代码示例

本文整理汇总了C#中DBHelper.ExecuteNonQuery方法的典型用法代码示例。如果您正苦于以下问题:C# DBHelper.ExecuteNonQuery方法的具体用法?C# DBHelper.ExecuteNonQuery怎么用?C# DBHelper.ExecuteNonQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBHelper的用法示例。


在下文中一共展示了DBHelper.ExecuteNonQuery方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ResetStore

        protected override void ResetStore()
        {
            var db = new DBHelper(SqlClientFactory.Instance, ConnectionString);

            var store = (BaseSqlStore)Store;

            var a = store.EventsTable;
            var b = store.ProjectionIndexTable;
            var c = store.ProjectionCheckpointTable;

            db.ExecuteNonQuery($"TRUNCATE TABLE [{a}]; TRUNCATE TABLE [{b}]; TRUNCATE TABLE [{c}];");
        }
开发者ID:promontis,项目名称:Even,代码行数:12,代码来源:SqlServer2012StoreTests.cs

示例2: ResetStore

        protected override void ResetStore()
        {
            var db = new DBHelper(DbProviderFactories.GetFactory("MySql.Data.MySqlClient"), ConnectionString);

            var store = (MySqlStore)Store;

            var a = store.EventsTable;
            var b = store.ProjectionIndexTable;
            var c = store.ProjectionCheckpointTable;

            db.ExecuteNonQuery($"TRUNCATE TABLE `{a}`; TRUNCATE TABLE `{b}`; TRUNCATE TABLE `{c}`;");
        }
开发者ID:Robin--,项目名称:Even,代码行数:12,代码来源:MySqlEventStoreTests.cs

示例3: ResetStore

        protected override void ResetStore()
        {
            var db = new DBHelper(DbProviderFactories.GetFactory("System.Data.SQLite"), ConnectionString);

            var store = (SQLiteStore)Store;

            var a = store.EventsTable;
            var b = store.ProjectionIndexTable;
            var c = store.ProjectionCheckpointTable;

            db.ExecuteNonQuery($"DELETE FROM {a}; DELETE FROM SQLITE_SEQUENCE WHERE NAME='{a}'; DELETE FROM {b}; DELETE FROM SQLITE_SEQUENCE WHERE NAME='{b}'; DELETE FROM {c}; DELETE FROM SQLITE_SEQUENCE WHERE NAME='{c}';");
        }
开发者ID:evendotnet,项目名称:Even,代码行数:12,代码来源:SQLiteEventStoreTests.cs

示例4: btnConfigUse_Click

 /// <summary>
 /// 应用配置
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnConfigUse_Click(object sender, EventArgs e)
 {
     try
     {
         TreeNode node = this.ConfigTree.SelectedNode;
         XmlElement ele = docoper.QueryEle(string.Format("/Base/ConfigAddress/Config[@Name='{0}']", node.Text));
         for (int i = 0; i < ele.ChildNodes.Count; i++)
         {
             XmlElement child = (XmlElement)ele.ChildNodes[i];
             if (child.GetAttribute("Type") == "Text" && !string.IsNullOrEmpty(child.GetAttribute("Path")))
             {
                 FileInfo fi = new FileInfo(child.GetAttribute("Path"));
                 if (fi.Exists)
                     fi.Delete();
                 FileStreamHelper.SaveText(fi.DirectoryName, fi.Name,
                     FileStreamHelper.ReadText(string.Format("{0}{1}{2}\\{3}", Application.StartupPath, configDataPath, ele.GetAttribute("Name"), child.GetAttribute("Name"))).Replace("{IP}", tbxConfigIP.Text));
             }
             else if (child.GetAttribute("Type") == "Sql" && !string.IsNullOrEmpty(child.GetAttribute("DataBase")))
             {
                 DBHelper db = new DBHelper(dataSourceList[child.GetAttribute("DataBase")], providerName);
                 db.ExecuteNonQuery(FileStreamHelper.ReadText(string.Format("{0}{1}{2}\\{3}", Application.StartupPath, configDataPath, ele.GetAttribute("Name"), child.GetAttribute("Name"))).Replace("{IP}", tbxConfigIP.Text));
             }
         }
         MessageBox.Show("应用成功");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
开发者ID:abc52406,项目名称:PbTool,代码行数:35,代码来源:MainForm.cs

示例5: btnDataOperClearLog_Click

        /// <summary>
        /// 点击“清除日志”
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDataOperClearLog_Click(object sender, EventArgs e)
        {
            try
            {
                if (DataSetOper.Count() > 0)
                {
                    foreach (var item in DataSetOper.Select(c => dataSourceList[c]))
                    {
                        DBHelper db = new DBHelper(item, providerName);
                        //因为ExecuteNonQuery方法不支持多个sql语句之间用GO连接,因此拆成多次执行
                        var SqlVersion = db.ExecuteScalar("select @@version").ToString();
                        if (SqlVersion.IndexOf("2005") > 0)
                        {
                            db.ExecuteNonQuery(string.Format("Backup Log {0} with no_log", db.DataBaseName));
                            db.ExecuteNonQuery(string.Format("dump transaction {0} with no_log", db.DataBaseName));
                            db.ExecuteNonQuery(string.Format(@"USE [{0}] 
DBCC SHRINKFILE ( 2 )", db.DataBaseName));
                        }
                        else if (SqlVersion.IndexOf("2008") > 0)
                        {
                            var logName = db.ExecuteScalar("select name from sys.database_files where type='1'");
                            db.ExecuteNonQuery(string.Format(@"USE [master] 
ALTER DATABASE {0} SET RECOVERY SIMPLE WITH NO_WAIT", db.DataBaseName));
                            db.ExecuteNonQuery(string.Format(@"ALTER DATABASE {0} SET RECOVERY SIMPLE   -- 简单模式 ", db.DataBaseName));
                            db.ExecuteNonQuery(string.Format(@"DBCC SHRINKFILE (N'{0}' , 11 , TRUNCATEONLY)", logName));
                            db.ExecuteNonQuery(string.Format(@"USE [master] 
ALTER DATABASE {0} SET RECOVERY FULL WITH NO_WAIT", db.DataBaseName));
                            db.ExecuteNonQuery(string.Format(@"USE [master] 
ALTER DATABASE {0} SET RECOVERY FULL   -- 还原为完全模式 ", db.DataBaseName));
                        }
                    }
                    MessageBox.Show("执行成功");
                }
                else
                    MessageBox.Show("请选择数据源");

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
开发者ID:abc52406,项目名称:PbTool,代码行数:47,代码来源:MainForm.cs

示例6: btnDataOperOK_Click

        /// <summary>
        /// 数据操作执行
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDataOperOK_Click(object sender, EventArgs e)
        {
            //如果是生成delete语句
            if (cbxBackupDelete.Checked || cbxBackupInsert.Checked)
            {
                if (DataSetOper.Count()>0)
                {
                    DoDataBaseExecute(DataSetOper.Select(c => dataSourceList[c]).ToArray(), cbxBackupDelete.Checked, cbxBackupInsert.Checked);
                    MessageBox.Show("执行成功");
                }
                else
                    MessageBox.Show("请选择数据源");
            }
            //如果是备份数据库
            else if (this.cbxBackUpDataBase.Checked)
            {
                try
                {
                    if (DataSetOper.Count() > 0)
                    {
                        foreach (var item in DataSetOper.Select(c => dataSourceList[c]))
                        {
                            DBHelper db = new DBHelper(item, providerName);
                            db.ExecuteNonQuery(string.Format("backup database {1} to disk='{0}\\{1}{2}.bak' With init",
                                this.tbxBakPath.Text.TrimEnd('\\'),
                                db.DataBaseName,
                                DateTime.Now.ToString("yyMMddHHmmss")), 7200);
                        }
                        MessageBox.Show("执行成功");
                    }
                    else
                        MessageBox.Show("请选择数据源");

                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
开发者ID:abc52406,项目名称:PbTool,代码行数:45,代码来源:MainForm.cs


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