本文整理汇总了C#中SQLite.SQLiteConnection.Close方法的典型用法代码示例。如果您正苦于以下问题:C# SQLiteConnection.Close方法的具体用法?C# SQLiteConnection.Close怎么用?C# SQLiteConnection.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLite.SQLiteConnection
的用法示例。
在下文中一共展示了SQLiteConnection.Close方法的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: App
public App()
{
// The root page of your application
MainPage = new ContentPage {
Content = new StackLayout {
VerticalOptions = LayoutOptions.Center,
Children = {
new Label {
XAlign = TextAlignment.Center,
Text = "Welcome to Xamarin Forms!"
}
}
}
};
// path to db
var path = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments), "mydb");
// open connection and attempt to apply encryption using PRAGMA statement
var conn = new SQLiteConnection (path);
conn.Execute ("PRAGMA key = 'passme'");
int v = conn.ExecuteScalar<int> ("SELECT count(*) FROM sqlite_master");
conn.Close ();
// open another connection, this time use wrong password. It will still open, but should fail the
// query (see docs on key PRAGMA https://www.zetetic.net/sqlcipher/sqlcipher-api/)
var conn2 = new SQLiteConnection (path);
conn2.Execute ("PRAGMA key = 'wrongpassword'");
int v2 = conn2.ExecuteScalar<int> ("SELECT count(*) FROM sqlite_master");
conn2.Close ();
}
示例3: getDrinks
public static List<Drink> getDrinks()
{
var conn = new SQLiteConnection (System.IO.Path.Combine (documentsFolder(), "database.db"));
var results = conn.Query<Drink> ("SELECT * FROM Drink");
conn.Close ();
return results;
}
示例4: Login_Loaded
async void Login_Loaded()
{
try
{
await ApplicationData.Current.LocalFolder.CreateFileAsync("Shopping.db3");
var path = Path.Combine(ApplicationData.Current.LocalFolder.Path, "Shopping.db3");
using (var db = new SQLite.SQLiteConnection(path))
{
// Create the tables if they don't exist
db.CreateTable<ShopLists>();
db.CreateTable<ShopAdmins>();
db.Commit();
db.Dispose();
db.Close();
}
ServiceReference1.SoapServiceSoapClient sc=new SoapServiceSoapClient();
sc.AllCouponsCompleted += (a, b) => MessageBox.Show(b.Result);
sc.AllCouponsAsync("hacking");
}
catch (Exception ex)
{
FaultHandling(ex.StackTrace);
}
}
示例5: addCompletedCircle
public static void addCompletedCircle(Circle circle)
{
completeCircles.Add(circle);
string dbPath = GetDBPath();
SQLiteConnection db;
db = new SQLiteConnection(dbPath);
db.Insert(circle);
var result = db.Query<Line>("SELECT * FROM Lines");
foreach (Line l in result) {
Console.WriteLine("Line DB: bx {0}, by {1}, ex {2}, ey {3}", l.begin.X, l.begin.Y, l.end.X, l.end.Y);
}
var result2 = db.Query<Circle>("SELECT * FROM Circles");
foreach (Circle c in result2) {
Console.WriteLine("Circle DB: cx {0}, cy {1}, p2x {2}, p2yy {3}", c.center.X, c.center.Y, c.point2.X, c.point2.Y);
}
db.Close();
db = null;
foreach (Line l in completeLines) {
Console.WriteLine("Line CL: bx {0}, by {1}, ex {2}, ey {3}", l.begin.X, l.begin.Y, l.end.X, l.end.Y);
}
foreach (Circle c in completeCircles) {
Console.WriteLine("Circle CC: cx {0}, cy {1}, p2x {2}, p2yy {3}", c.center.X, c.center.Y, c.point2.X, c.point2.Y);
}
}
示例6: CheckAndCreateDatabase
// This method checks to see if the database exists, and if it doesn't, it creates
// it and inserts some data
protected void CheckAndCreateDatabase(string dbName)
{
// create a connection object. if the database doesn't exist, it will create
// a blank database
using(SQLiteConnection db = new SQLiteConnection (GetDBPath (dbName)))
{
// create the tables
db.CreateTable<Person> ();
// skip inserting data if it already exists
if(db.Table<Person>().Count() > 0)
return;
// declare vars
List<Person> people = new List<Person> ();
Person person;
// create a list of people that we're going to insert
person = new Person () { FirstName = "Peter", LastName = "Gabriel" };
people.Add (person);
person = new Person () { FirstName = "Thom", LastName = "Yorke" };
people.Add (person);
person = new Person () { FirstName = "J", LastName = "Spaceman" };
people.Add (person);
person = new Person () { FirstName = "Benjamin", LastName = "Gibbard" };
people.Add (person);
// insert our people
db.InsertAll (people);
// close the connection
db.Close ();
}
}
示例7: ViewWillAppear
public override void ViewWillAppear(bool animated)
{
base.ViewWillAppear (animated);
// This is not double loading becuase it is a new _loader each time and the _newSL is a get set
_loader = new List<SongToSave> ();
_dbWorker = new DBWorker ();
_dbWorker.StartDBWorker ();
dbPath = _dbWorker.GetPathToDb ();
var conn = new SQLiteConnection (dbPath);
// this seems redundant.
foreach (var item in conn.Table<SongToSave>()) {
var tempSong = new SongToSave () {
BookTitle = item.BookTitle,
BookAuthor = item.BookAuthor,
PlayPosition = item.PlayPosition
};
_loader.Add (tempSong);
}
conn.Close ();
// why am I using two list?
_newSL = _loader;
TableView.ReloadData ();
}
示例8: criando_populando
public void criando_populando(string s)
{
dbConn = new SQLiteConnection(DB_path);
SQLiteCommand cmd = new SQLiteCommand(dbConn);
cmd.CommandText = s;
cmd.ExecuteNonQuery();
dbConn.Close();
}
示例9: LendoFabricantesLocal
public List<Fabricante> LendoFabricantesLocal()
{
using(dbConn = new SQLiteConnection(DB_path))
{
//dbConn.CreateTable<Fabricante>();
List<Fabricante> fabricantes = dbConn.Table<Fabricante>().ToList();
dbConn.Close();
return fabricantes;
}
}
示例10: clearLines
public static void clearLines()
{
completeLines.Clear();
string dbPath = GetDBPath();
SQLiteConnection db;
db = new SQLiteConnection(dbPath);
db.DeleteAll<Line>();
db.Close();
db = null;
}
示例11: LoadSavedSyncParams
public static SyncParams LoadSavedSyncParams()
{
SyncParams param = null;
SQLiteConnection db = new SQLiteConnection(SyncController.DatabasePath);
db.CreateTable<SyncParams>();
if (db.Table<SyncParams>().Count() != 0)
param = db.Table<SyncParams>().First();
else
param = new SyncParams();
db.Close();
return param;
}
示例12: CheckAndCreateDatabase
// method to check for db exsistence, and create and insert if not found
protected void CheckAndCreateDatabase(string pathToDatabase)
{
using (var db = new SQLiteConnection (pathToDatabase)) {
db.CreateTable<SongToSave> ();
//this doesn't seem to make sense why it is here because I am creating it either way I think ^
if (db.Table<SongToSave> ().Count () > 0) {
//Console.WriteLine ("The DB is already at:" + pathToDatabase); // debugging
return;
}
db.Close ();
}
}
示例13: addAssetType
// public static bool saveChanges()
// {
// // Save to db
// string dbPath = GetDBPath();
// var db = new SQLiteConnection(dbPath);
// db.DeleteAll<BNRItem>();
// db.BeginTransaction();
// db.InsertAll(allItems);
// db.Commit();
// db.Close();
// return true;
// Archive method of saving
// // returns success or failure // For archiving method of saving
// string path = itemArchivePath(); // For archiving method of saving
// NSMutableArray newArray = new NSMutableArray(); // For archiving method of saving
// foreach (BNRItem item in allItems) { // For archiving method of saving
// newArray.Add(item); // For archiving method of saving
// } // For archiving method of saving
// return NSKeyedArchiver.ArchiveRootObjectToFile(newArray, path); // For archiving method of saving
// }
public static void addAssetType(string assetType)
{
string dbPath = GetDBPath();
SQLiteConnection db;
if (File.Exists(dbPath)) {
db = new SQLiteConnection(dbPath);
db.BeginTransaction();
var at = new BNRAssetType();
at.assetType = assetType;
allAssetTypes.Add(at);
db.Insert(at);
db.Commit();
db.Close();
}
}
示例14: FindCourseSchedule
public static CourseSchedule FindCourseSchedule (decimal classId)
{
CheckAndCreateDatabase ();
string path = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), "CourseSchedule.sqlite");
using (SQLiteConnection db = new SQLiteConnection (path)) {
// create the tables
var classSchedule = db.Find<CourseSchedule> (c => c.ClassId == classId);
// close the connection
db.Close ();
return classSchedule;
}
}
示例15: CheckAndCreateDatabase
// This method checks to see if the database exists, and if it doesn't, it creates
// it and inserts some data
public static void CheckAndCreateDatabase ()
{
string path = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), "CourseSchedule.sqlite");
// create a connection object. if the database doesn't exist, it will create
// a blank database
using (SQLiteConnection db = new SQLiteConnection (path)) {
// create the tables
db.CreateTable<CourseSchedule> ();
// close the connection
db.Close ();
}
}