当前位置: 首页>>代码示例>>C#>>正文


C# SQLite.SQLiteConnection.ExecuteScalar方法代码示例

本文整理汇总了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);
         }
     }
 }
开发者ID:ktei,项目名称:JsonResxEditor,代码行数:17,代码来源:PreferenceService.cs

示例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);
            }
        }
开发者ID:mokth,项目名称:merpCS,代码行数:36,代码来源:LoginActivity.cs

示例3: HasProject

 public bool HasProject()
 {
     using (var db = new SQLite.SQLiteConnection(Settings.DatabasePath))
     {
         return db.ExecuteScalar<int>("select count(Id) from Project") > 0;
     }
 }
开发者ID:ktei,项目名称:JsonResxEditor,代码行数:7,代码来源:ProjectService.cs

示例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;
     }
 }
开发者ID:ktei,项目名称:JsonResxEditor,代码行数:7,代码来源:LocaleService.cs


注:本文中的SQLite.SQLiteConnection.ExecuteScalar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。