本文整理汇总了C#中SQLite.SQLiteConnection.DropTable方法的典型用法代码示例。如果您正苦于以下问题:C# SQLiteConnection.DropTable方法的具体用法?C# SQLiteConnection.DropTable怎么用?C# SQLiteConnection.DropTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLite.SQLiteConnection
的用法示例。
在下文中一共展示了SQLiteConnection.DropTable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InserindoListaFabricantes
public void InserindoListaFabricantes(List<Fabricante> fabricantes)
{
using (var dbConn = new SQLiteConnection(DB_path))
{
dbConn.DropTable<Fabricante>();
dbConn.Dispose();
dbConn.Close();
}
foreach (Fabricante f in fabricantes)
this.Inserindo(f);
}
示例2: KspMods
public KspMods(string a_InstallationDirectory, string a_ModPath )
{
InstallationDirectory = a_InstallationDirectory;
ModDirectory = a_ModPath;
db = new SQLiteConnection("kmm.sqlite");
// make sure the table exists
if (db.GetTableInfo("KMMInfo").Count == 0)
{
db.CreateTable<KMMInfo>();
}
var tables = new Type[] { typeof(InstalledMods), typeof(ModFiles), typeof(InstalledFiles) };
foreach (var table in tables)
{
var info = db.GetTableInfo(table.Name);
if (info.Count == 0)
db.CreateTable(table);
}
// oh noez it does not match
if (db.Table<KMMInfo>().Count() == 0 || db.Table<KMMInfo>().First().Version != GetAssemblyVersion())
{
// salvage data
var installed_mods = db.Table<InstalledMods>().ToList();
db.DropTable<InstalledMods>();
db.CreateTable<InstalledMods>();
db.InsertAll(installed_mods);
var mod_files = db.Table<ModFiles>().ToList();
db.DropTable<ModFiles>();
db.CreateTable<ModFiles>();
db.InsertAll(mod_files);
var installed_files = db.Table<InstalledFiles>().ToList();
db.DropTable<InstalledFiles>();
db.CreateTable<InstalledFiles>();
db.InsertAll(installed_files);
}
// make sure the table is filled
if (db.Table<KMMInfo>().Count() == 0)
{
var nfo = new KMMInfo()
{
Version = GetAssemblyVersion()
};
db.Insert(nfo);
}
}
示例3: Drop
public void Drop()
{
using (var db = new SQLiteConnection(DbPath))
{
db.DropTable<TracklistItem>();
}
}
示例4: Drop
public void Drop()
{
using (var connection = new SQLiteConnection(_dbPath))
{
connection.DropTable<Account>();
}
}
示例5: Exec
public static void Exec()
{
using (sql.SQLiteConnection connection = new sql.SQLiteConnection("testdb.db"))
{
connection.CreateTable(typeof (Table));
connection.Insert(typeof (A));
connection.DropTable<Table>();
}
}
示例6: SaveEvents
public static void SaveEvents (List<Event> eventsList)
{
string path = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), "Event.sqlite");
var db = new SQLiteConnection (path);
db.DropTable<Event> ();
db.CreateTable<Event> ();
db.InsertAll (eventsList);
}
示例7: Setup
public void Setup()
{
_cache.ApplicationName = AppName;
_expectedDatabasePath = Path.Combine(
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), AppName),
"SimpleObjectCache");
Directory.CreateDirectory(_expectedDatabasePath);
_connection = new SQLiteConnection(Path.Combine(_expectedDatabasePath, "cache.db3"));
_connection.DropTable<CacheElement>();
}
示例8: createDatabase
public string createDatabase()
{
try
{
string folder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
mCon = new SQLiteConnection(System.IO.Path.Combine(folder, "db.db"));
mCon.DropTable<User>();
{
mCon.CreateTable<User>();
return "Database created";
}
}
catch (SQLiteException ex)
{
return ex.Message;
}
}
示例9: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
// Figure out where the SQLite database will be.
var documents = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
_pathToDatabase = Path.Combine(documents, "db_sqlite-net.db");
using (var conn= new SQLite.SQLiteConnection(_pathToDatabase))
{
conn.DropTable<Terms>();
conn.CreateTable<Terms>();
}
btnAceptar.TouchUpInside += (sender, e) => {
insertTerms();
NavigationController.PopViewController(true);
};
btnCancelar.TouchUpInside += (sender, e) => NavigationController.PopViewController (true);
}
示例10: ClearDatabase
public async Task ClearDatabase ()
{
using (var connection = new SQLiteConnection (dbPath, true))
await Task.Run (() => connection.DropTable<BikeTrip> ()).ConfigureAwait (false);
}
示例11: AllTableDrop
//테이블 전체 삭제 및 재생성
public bool AllTableDrop()
{
bool result = false;
try
{
//DB Connection
SQLiteConnection conn = new SQLiteConnection(dbPath, true);
//테이블 삭제
conn.DropTable<DBForm.MoneyDBForm>();
conn.DropTable<DBForm.ExpenseCategoryForm>();
conn.DropTable<DBForm.IncomeCategoryForm>();
//연결종료
conn.Close();
//새로 테이블을 만든다.
CreateDatabaseAsync();
//카테고리 새로 세팅
BasicSetting();
//어플리케이션종료하기위해 결과 값을 리턴한다.
result = true;
}
catch (Exception ex)
{
ex.Message.ToString();
result = false;
}
return result;
}
示例12: DeleteAllContact
//Delete all contactlist or delete Contacts table
public void DeleteAllContact()
{
using (var dbConn = new SQLiteConnection(App.DB_PATH))
{
//dbConn.RunInTransaction(() =>
// {
dbConn.DropTable<GhiChu>();
dbConn.CreateTable<GhiChu>();
dbConn.Dispose();
dbConn.Close();
//});
}
}
示例13: DeleteAllContact
}//DELETE CONTACT THAT I CHOSE
//DELETE ALL
public void DeleteAllContact()
{
using (var dbConn = new SQLiteConnection(App.DB_PATH))
{
dbConn.DropTable<Contactos>();
dbConn.CreateTable<Contactos>();
dbConn.Dispose();
dbConn.Close();
}
}
示例14: Main
public static void Main (string[] args)
{
Console.WriteLine ("Hello SQLite-net Data!");
/*
//Get the path to the folder where the database is stored.
// Notes: The Path class performs operations on strings that contain file path info
// Path.Combine appends the second path to the first path
// Environment.GetSpecialFolderPath gets the path to special pre-defined folders
// on Windows, the SpecialFolder enum defines: ProgramFiles, System, AppData, etc.
// on Android ...
string dbPath = Path.Combine (
Environment.GetFolderPath (Environment.SpecialFolder.Personal), "stocks.db3");
*/
/*
// Check for an existing db file and only create a new one if it doesn't exist
bool exists = File.Exists (dbPath);
if (!exists) {
// Need to create the database and seed it with some data.
SQLiteConnection.CreateFile (dbPath);
*/
// We're using a file in Assets instead of the one defined above
//string dbPath = Directory.GetCurrentDirectory ();
string dbPath = @"../../../DataAccess-Android/Assets/stocks.db3";
var db = new SQLiteConnection (dbPath);
// Create a Stocks table
//if (db.CreateTable (Mono.CSharp.TypeOf(Stock)) != 0)
db.DropTable<Stock>();
if (db.CreateTable<Stock>() == 0)
{
// A table already exixts, delete any data it contains
db.DeleteAll<Stock> ();
}
// Create a new stock and insert it into the database
var newStock = new Stock ();
newStock.Symbol = "APPL";
newStock.Name = "Apple";
newStock.ClosingPrice = 93.22m;
int numRows = db.Insert (newStock);
Console.WriteLine ("Number of rows inserted = {0}", numRows);
// Insert some more stocks
db.Insert(new Stock() {Symbol = "MSFT", Name = "Microsoft", ClosingPrice = 55.25m});
db.Insert (new Stock() {Symbol = "GOOG", Name = "Google", ClosingPrice = 15.25m});
db.Insert (new Stock() {Symbol = "SSNLF", Name = "Samsung", ClosingPrice = 25.25m});
db.Insert (new Stock() {Symbol = "AMZN", Name = "Amazon", ClosingPrice = 35.25m});
db.Insert (new Stock() {Symbol = "MMI", Name = "Motorola Mobility", ClosingPrice = 45.25m});
db.Insert (new Stock() {Symbol = "FB", Name = "Facebook", ClosingPrice = 65.25m});
// Read the stock from the database
// Use the Get method with a query expression
Stock singleItem = db.Get<Stock> (x => x.Name == "Google");
Console.WriteLine ("Stock Symbol for Google: {0}", singleItem.Symbol);
singleItem = db.Get<Stock> (x => x.ClosingPrice >= 30.0m);
Console.WriteLine ("First stock priced at or over 30: {0}, price: {1}",
singleItem.Symbol, singleItem.ClosingPrice);
// Use the Get method with a primary key
singleItem = db.Get<Stock> ("FB");
Console.WriteLine ("Stock Name for Symbol FB: {0}", singleItem.Symbol);
// Query using SQL
var stocksStartingWithA = db.Query<Stock> ("SELECT * FROM Stocks WHERE Symbol LIKE ?", "A%");
foreach(Stock stock in stocksStartingWithA)
Console.WriteLine ("Stock starting with A: {0}", stock.Symbol);
// Query using Linq
var stocksStartingWithM = from s in db.Table<Stock> () where s.Symbol.StartsWith ("M") select s;
foreach(Stock stock in stocksStartingWithM)
Console.WriteLine ("Stock starting with M: {0}", stock.Symbol);
}
示例15: DeleteActivities
//~~~delete all activities
public void DeleteActivities ()
{
using (var dbConn = new SQLiteConnection(this.KreyosDBPath))
{
//dbConn.RunInTransaction(() =>
// {
dbConn.DropTable<Kreyos_User_Activities>();
dbConn.CreateTable<Kreyos_User_Activities>();
dbConn.Dispose();
dbConn.Close();
//});
}
}