本文整理汇总了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);
}
}
}
示例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;
}
示例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);
}
}
}
示例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));
}
}
示例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");
}