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


C# System.Data.SQLite.SQLiteConnection.Execute方法代码示例

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


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

示例1: Application_Start

        protected void Application_Start(object sender, EventArgs e)
        {
            InitProfilerSettings();

            var dbFile = HttpContext.Current.Server.MapPath("~/App_Data/TestMiniProfiler.sqlite");
            if (System.IO.File.Exists(dbFile))
            {
                File.Delete(dbFile);
            }

            using (var cnn = new System.Data.SQLite.SQLiteConnection(WcfCommon.ConnectionString))
            {
                cnn.Open();
                cnn.Execute("create table RouteHits(RouteName,HitCount)");
                // we need some tiny mods to allow sqlite support
                foreach (var sql in SqliteMiniProfilerStorage.TableCreationSQL)
                {
                    cnn.Execute(sql);
                }
            }
        }
开发者ID:nightbob3,项目名称:MiniProfiler,代码行数:21,代码来源:Global.asax.cs

示例2: InsertData

        private static UserId InsertData()
        {
            var id = new UserId("Abc12c");
            using (var connection = new System.Data.SQLite.SQLiteConnection(cnStr))
            {
                connection.Open();
                connection.Execute("INSERT INTO Users (Id, Age, Name) VALUES (@Id, @Age, @Name)",
                    new {
                        Age = 31,
                        Id = id,
                        Name = "Peter Gill"
                    });
            }

            return id;
        }
开发者ID:majorsilence,项目名称:Dev,代码行数:16,代码来源:Program.cs

示例3: RecreateDatabase

        /// <summary>
        /// Used for testing purposes - destroys and recreates the SQLITE file with needed tables.
        /// </summary>
        /// <param name="extraTablesToCreate">The Extra Tables To Create.</param>
        public void RecreateDatabase(params string[] extraTablesToCreate)
        {
            var path = ConnectionString.Replace("Data Source = ", string.Empty); // hacky

            if (File.Exists(path))
            {
                File.Delete(path);
            }

            using (var cnn = new System.Data.SQLite.SQLiteConnection(MvcApplication.ConnectionString))
            {
                cnn.Open();

                // we need some tiny mods to allow sqlite support 
                foreach (var sql in TableCreationScripts.Union(extraTablesToCreate))
                {
                    cnn.Execute(sql);
                }
            }
        }
开发者ID:CurufinweU,项目名称:dotnet,代码行数:24,代码来源:SqliteMiniProfilerStorage.cs

示例4: Application_Start

        protected void Application_Start()
        {
            RegisterRoutes(RouteTable.Routes);

            InitProfilerSettings();

            var dbFile = HttpContext.Current.Server.MapPath("~/App_Data/TestMiniProfiler.sqlite");
            if (System.IO.File.Exists(dbFile))
            {
                File.Delete(dbFile);
            }

            using (var cnn = new System.Data.SQLite.SQLiteConnection(MvcApplication.ConnectionString))
            {
                cnn.Open();
                cnn.Execute("create table RouteHits(RouteName,HitCount)");
                // we need some tiny mods to allow sqlite support
                foreach (var sql in SqliteMiniProfilerStorage.TableCreationSQL)
                {
                    cnn.Execute(sql);
                }
            }

            var efDb = HttpContext.Current.Server.MapPath("~/App_Data/SampleWeb.EFCodeFirst.EFContext.sdf");
            if (System.IO.File.Exists(efDb))
            {
                File.Delete(efDb);
            }

            //Setup profiler for Controllers via a Global ActionFilter
            GlobalFilters.Filters.Add(new ProfilingActionFilter());

            // initialize automatic view profiling
            var copy = ViewEngines.Engines.ToList();
            ViewEngines.Engines.Clear();
            foreach (var item in copy)
            {
                ViewEngines.Engines.Add(new ProfilingViewEngine(item));
            }
        }
开发者ID:robertmilne,项目名称:MVC-Mini-Profiler,代码行数:40,代码来源:Global.asax.cs

示例5: Setup

        private static void Setup()
        {
            var projLoc = Assembly.GetAssembly(typeof(Program)).Location;
            var projFolder = Path.GetDirectoryName(projLoc);

            if (File.Exists(projFolder + "\\Test.sqlite"))
            {
                File.Delete(projFolder + "\\Test.sqlite");
            }
            var connectionString = "Data Source = " + projFolder + "\\Test.sqlite;";
            using (var connection = new System.Data.SQLite.SQLiteConnection(connectionString))
            {
                connection.Open();
                connection.Execute(@" create table Users (Id int IDENTITY(1,1) not null, Name nvarchar(100) not null, Age int not null) ");
            }

            cnStr = connectionString;
            Console.WriteLine("Created database");
        }
开发者ID:majorsilence,项目名称:Dev,代码行数:19,代码来源:Program.cs


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