本文整理汇总了C#中SQLite.SQLiteConnection.ExecuteScalar方法的典型用法代码示例。如果您正苦于以下问题:C# SQLite.SQLiteConnection.ExecuteScalar方法的具体用法?C# SQLite.SQLiteConnection.ExecuteScalar怎么用?C# SQLite.SQLiteConnection.ExecuteScalar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLite.SQLiteConnection
的用法示例。
在下文中一共展示了SQLite.SQLiteConnection.ExecuteScalar方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Save
public void Save(Preference model)
{
using (var db = new SQLite.SQLiteConnection(Settings.DatabasePath))
{
var existingCount = db.ExecuteScalar<int>("select count(Name) from Preference where Name = ?",
model.Name);
if (existingCount == 0)
{
db.Insert(model);
}
else
{
db.Execute("update Preference set Value = ? where Name = ?",
model.Value, model.Name);
}
}
}
示例2: UpdateDatbase
private void UpdateDatbase()
{
try {
using (var conn = new SQLite.SQLiteConnection (pathToDatabase)) {
var num = conn.ExecuteScalar<Int32> ("SELECT count(name) FROM sqlite_master WHERE type='table' and name='CNNote'", new object[]{ });
int count = Convert.ToInt32 (num);
if (count > 0)
return;
conn.CreateTable<CNNote> ();
conn.CreateTable<CNNoteDtls> ();
conn.DropTable<AdPara> ();
conn.CreateTable<AdPara> ();
conn.DropTable<AdNumDate> ();
conn.CreateTable<AdNumDate> ();
conn.DropTable<CompanyInfo> ();
conn.CreateTable<CompanyInfo> ();
conn.DropTable<Trader> ();
conn.CreateTable<Trader> ();
conn.DropTable<AdUser> ();
conn.CreateTable<AdUser> ();
string sql = @"ALTER TABLE Invoice RENAME TO sqlitestudio_temp_table;
CREATE TABLE Invoice (invno varchar PRIMARY KEY NOT NULL, trxtype varchar, invdate bigint, created bigint, amount float, taxamt float, custcode varchar, description varchar, uploaded bigint, isUploaded integer, isPrinted integer);
INSERT INTO Invoice (invno, trxtype, invdate, created, amount, taxamt, custcode, description, uploaded, isUploaded,isPrinted) SELECT invno, trxtype, invdate, created, amount, taxamt, custcode, description, uploaded, isUploaded,0 FROM sqlitestudio_temp_table;
DROP TABLE sqlitestudio_temp_table";
string[] sqls = sql.Split (new char[]{ ';' });
foreach (string ssql in sqls) {
conn.Execute (ssql, new object[]{ });
}
}
} catch (Exception ex) {
AlertShow (ex.Message);
}
}
示例3: HasProject
public bool HasProject()
{
using (var db = new SQLite.SQLiteConnection(Settings.DatabasePath))
{
return db.ExecuteScalar<int>("select count(Id) from Project") > 0;
}
}
示例4: Exists
public bool Exists(string code, int projectId)
{
using (var db = new SQLite.SQLiteConnection(Settings.DatabasePath))
{
return db.ExecuteScalar<int>("select count(Code) from Locale where ProjectId = ? and Code = ?", projectId, code) > 0;
}
}