本文整理汇总了C#中SQLite.SQLiteConnection类的典型用法代码示例。如果您正苦于以下问题:C# SQLiteConnection类的具体用法?C# SQLiteConnection怎么用?C# SQLiteConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SQLiteConnection类属于SQLite命名空间,在下文中一共展示了SQLiteConnection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Drop
public void Drop()
{
using (var connection = new SQLiteConnection(_dbPath))
{
connection.DropTable<Account>();
}
}
示例2: BasicSetting
//기본 카테고리 생성
public void BasicSetting()
{
try
{
//DB와 연결
SQLiteConnection conn = new SQLiteConnection(dbPath, true);
//기본 카테고리들 생성
string[] basicIncomeCategory = { "Salary", "Interest", "Installment Saving", "Allowance" };
string[] basicExpenseCategory = { "Electronics", "Food", "Internet", "Transport", "Housing" };
//돌아가면서 Income category insert
foreach (string tempCategory in basicIncomeCategory)
{
IncomeCategoryForm basicCategory = new IncomeCategoryForm
{
categoryName = tempCategory
};
conn.Insert(basicCategory);
}
//돌아가면서 expense category insert
foreach (string tempCategory in basicExpenseCategory)
{
ExpenseCategoryForm expenseCategory = new ExpenseCategoryForm
{
categoryName = tempCategory
};
conn.Insert(expenseCategory);
}
}
catch (Exception ex)
{
ex.Message.ToString();
}
}
示例3: GetLastLocation
private async Task<Location> GetLastLocation()
{
using (var db = new SQLiteConnection(Database.DatabasePath))
{
return db.Table<Location>().OrderByDescending(x => x.Timestamp).FirstOrDefault();
}
}
示例4: CheckAuth
public static async Task<Exception> CheckAuth(string id, string pass,SQLiteConnection connection)
{
pass = base64Encode (pass);
var httpClient = new HttpClient ();
Exception error;
httpClient.Timeout = TimeSpan.FromSeconds (20);
string contents;
Task<string> contentsTask = httpClient.GetStringAsync ("http://www.schoolapi.somee.com/dangnhap/"+id+"/"+pass);
try
{
contents = await contentsTask;
}
catch(Exception e) {
error =new Exception("Xảy Ra Lỗi Trong Quá Trình Kết Nối Server");
return error;
}
if (contents.Contains ("false")) {
error=new Exception("Mã Sinh Viên Hoặc Mật Khẩu Không Đúng");
return error;
}
User usr = new User ();
usr.Password = pass;
usr.Id = id;
Task<string> contentNameTask = httpClient.GetStringAsync ("http://www.schoolapi.somee.com/user/" + id);
contents=await contentNameTask;
XDocument doc = XDocument.Parse (contents);
usr.Hoten= doc.Root.Elements().ElementAt(0).Elements().ElementAt(1).Value.ToString();
int i = AddUser (connection, usr);
return null;
}
示例5: Initialize
public void Initialize()
{
using (var db = new SQLiteConnection(DbPath))
{
db.CreateTable<TracklistItem>();
}
}
示例6: InsertPost
public void InsertPost(Post post)
{
using(Connection = new SQLiteConnection(this.DbPath))
{
this.Connection.Insert(post);
}
}
示例7: getAll
public static List<DiemThi> getAll(SQLiteConnection connection)
{
list = new List<DiemThi>();
DataProvider dtb = new DataProvider (connection);
list = dtb.GetAllDT ();
return list;
}
示例8: AddCategoryOffline
public bool AddCategoryOffline(CategoryOfflineViewModel newCategoryOffline, string _synced)
{
bool result = false;
try
{
using (var db = new SQLite.SQLiteConnection(_dbPath))
{
CategoryOffline objCategoryOffline = new CategoryOffline();
objCategoryOffline.categoryId = Convert.ToString(newCategoryOffline.categoryId);
objCategoryOffline.organizationId = Convert.ToString(newCategoryOffline.organizationId);
objCategoryOffline.categoryCode = Convert.ToString(newCategoryOffline.categoryCode);
objCategoryOffline.categoryDescription = newCategoryOffline.categoryDescription;
objCategoryOffline.parentCategoryId = newCategoryOffline.parentCategoryId;
objCategoryOffline.imageName = newCategoryOffline.imageName;
objCategoryOffline.active = newCategoryOffline.active;
objCategoryOffline.synced = _synced; // i.e. Need to synced when online and Update the synced status = "True"
db.RunInTransaction(() =>
{
db.Insert(objCategoryOffline);
});
}
result = true;
}//try
catch (Exception ex)
{
}//catch
return result;
}
示例9: DoSomeDataAccess
/// <returns>
/// Output of test query
/// </returns>
public static string DoSomeDataAccess ()
{
var output = "";
output += "\nCreating database, if it doesn't already exist";
string dbPath = Path.Combine (
Environment.GetFolderPath (Environment.SpecialFolder.Personal), "ormdemo.db3");
var db = new SQLiteConnection (dbPath);
db.CreateTable<Stock> ();
if (db.Table<Stock> ().Count() == 0) {
// only insert the data if it doesn't already exist
var newStock = new Stock ();
newStock.Symbol = "AAPL";
db.Insert (newStock);
newStock = new Stock ();
newStock.Symbol = "GOOG";
db.Insert (newStock);
newStock = new Stock ();
newStock.Symbol = "MSFT";
db.Insert (newStock);
}
output += "\nReading data using Orm";
var table = db.Table<Stock> ();
foreach (var s in table) {
output += "\n" + s.Id + " " + s.Symbol;
}
return output;
}
示例10: ProcessPath
public static void ProcessPath(string databasePath, string filePath)
{
//TODO ensure directory exists for the database
using (var db = new SQLiteConnection(databasePath)) {
DatabaseLookups.CreateTables(db);
var hdCollection = DriveUtilities.ProcessDriveList(db);
var start = DateTime.Now;
List<string> arrHeaders = DriveUtilities.GetFileAttributeList(db);
var directory = new DirectoryInfo(filePath);
var driveLetter = directory.FullName.Substring(0, 1);
//TODO line it up with the size or the serial number since we will have removable drives.
var drive = hdCollection.FirstOrDefault(letter => letter.DriveLetter.Equals(driveLetter, StringComparison.OrdinalIgnoreCase));
if (directory.Exists) {
ProcessFolder(db, drive, arrHeaders, directory);
}
//just in case something blew up and it is not committed.
if (db.IsInTransaction) {
db.Commit();
}
db.Close();
}
}
示例11: Update
public void Update(Account currentAccount)
{
using (var connection = new SQLiteConnection(_dbPath))
{
connection.Update(currentAccount);
}
}
示例12: Initialize
public void Initialize()
{
using (var connection = new SQLiteConnection(_dbPath))
{
connection.CreateTable<Account>();
}
}
示例13: GetAccounts
public List<Account> GetAccounts()
{
using (var connection = new SQLiteConnection(_dbPath))
{
return connection.Table<Account>().ToList();
}
}
示例14: CreateDatabase
/// <summary>
/// Creates the database if it doesn't already exist.
/// </summary>
internal static void CreateDatabase()
{
try
{
if (!File.Exists(IndexLocation))
{
string absolutePath = HostingEnvironment.MapPath(VirtualCachePath);
if (absolutePath != null)
{
DirectoryInfo directoryInfo = new DirectoryInfo(absolutePath);
if (!directoryInfo.Exists)
{
// Create the directory.
Directory.CreateDirectory(absolutePath);
}
}
using (SQLiteConnection connection = new SQLiteConnection(IndexLocation))
{
connection.CreateTable<CachedImage>();
}
}
}
catch (Exception ex)
{
throw ex;
}
}
示例15: SaveLTRemind
public static void SaveLTRemind(SQLiteConnection connection,LTRemindItem item)
{
DataProvider dtb = new DataProvider (connection);
if (dtb.GetLTRemind (item.MaMH, item.NamHoc, item.HocKy) == null) {
dtb.AddRemindLT (item);
}
}