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


C# SQLiteCommand.Close方法代码示例

本文整理汇总了C#中System.Data.SQLite.SQLiteCommand.Close方法的典型用法代码示例。如果您正苦于以下问题:C# SQLiteCommand.Close方法的具体用法?C# SQLiteCommand.Close怎么用?C# SQLiteCommand.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.SQLite.SQLiteCommand的用法示例。


在下文中一共展示了SQLiteCommand.Close方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Init

        public void Init()
        {
            try
            {
                string path = Path.Combine(Program.Config.LauncherDir, "cards.cdb");
                m_cards = new Dictionary<int, CardInfos>();

                if (!File.Exists(path)) return;

                SQLiteConnection connection = new SQLiteConnection("Data Source=" + path);
                connection.Open();
                SQLiteDataReader reader = new SQLiteCommand("SELECT id, alias, type, level, race, attribute, atk, def FROM datas", connection).ExecuteReader();

                while (reader.Read())
                {
                    int id = reader.GetInt32(0);

                    CardInfos infos = new CardInfos(id)
                    {
                        AliasId = reader.GetInt32(1),
                        Type = reader.GetInt32(2),
                        Level = reader.GetInt32(3),
                        Race = reader.GetInt32(4),
                        Attribute = reader.GetInt32(5),
                        Atk = reader.GetInt32(6),
                        Def = reader.GetInt32(7)
                    };
                    m_cards.Add(id, infos);
                }

                reader.Close();
                reader = new SQLiteCommand("SELECT id, name, desc FROM texts", connection).ExecuteReader();

                while (reader.Read())
                {
                    int key = reader.GetInt32(0);
                    if (m_cards.ContainsKey(key))
                    {
                        m_cards[key].Name = reader.GetString(1);
                        m_cards[key].CleanedName = m_cards[key].Name.Trim().ToLower().Replace("-", " ").Replace("'", " ").Replace("   ", " ").Replace("  ", " ");
                        m_cards[key].Description = reader.GetString(2);
                    }
                }
                connection.Close();
            }
            catch (Exception)
            {
            }
        }
开发者ID:BrendaLove,项目名称:DevProLauncher,代码行数:49,代码来源:CardManager.cs

示例2: Init

 public void Init()
 {
     try
     {
         m_cards = new Dictionary<int, CardInfos>();
         string str = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? "";
         string str2 = Path.Combine(str, @"cards.cdb");
         if (!File.Exists(str2)) return;
         SQLiteConnection connection = new SQLiteConnection("Data Source=" + str2);
         connection.Open();
         SQLiteDataReader reader = new SQLiteCommand("SELECT id, alias, type, level, race, attribute, atk, def FROM datas", connection).ExecuteReader();
         while (reader.Read())
         {
             int id = reader.GetInt32(0);
             CardInfos infos = new CardInfos(id)
             {
                 AliasId = reader.GetInt32(1),
                 Type = reader.GetInt32(2),
                 Level = reader.GetInt32(3),
                 Race = reader.GetInt32(4),
                 Attribute = reader.GetInt32(5),
                 Atk = reader.GetInt32(6),
                 Def = reader.GetInt32(7)
             };
             m_cards.Add(id, infos);
         }
         reader.Close();
         reader = new SQLiteCommand("SELECT id, name, desc FROM texts", connection).ExecuteReader();
         while (reader.Read())
         {
             int key = reader.GetInt32(0);
             if (m_cards.ContainsKey(key))
             {
                 m_cards[key].Name = reader.GetString(1);
                 m_cards[key].CleanedName = m_cards[key].Name.Trim().ToLower().Replace("-", " ").Replace("'", " ").Replace("   ", " ").Replace("  ", " ");
                 m_cards[key].Description = reader.GetString(2);
             }
         }
         connection.Close();
         Loaded = true;
     }
     catch (Exception)
     {
         MessageBox.Show("Error loading cards.cdb");
     }
 }
开发者ID:TerryXY,项目名称:DevProLauncher,代码行数:46,代码来源:CardManager.cs

示例3: values

            public int this[string Key]
            {
                set
                {
                    Context.Create();

                    if (Context.Connection.SQLiteCountByColumnName(Context.Name, "Key", Key) == 0)
                    {
                        var sql = "insert into ";
                        sql += Context.Name;
                        sql += " (Key, ValueInt32) values (";
                        sql += "'";
                        sql += Key;
                        sql += "'";
                        sql += ", ";
                        sql += ((object)value).ToString();
                        sql += ")";



                        new SQLiteCommand(sql, Context.Connection).ExecuteNonQuery();

                        return;
                    }

                    #region update
                    {
                        var sql = "update ";
                        sql += Context.Name;
                        sql += " set ValueInt32 = ";
                        sql += ((object)value).ToString();
                        sql += " where Key = ";
                        sql += "'";
                        sql += Key;
                        sql += "'";

                        new SQLiteCommand(sql, Context.Connection).ExecuteNonQuery();
                    }
                    #endregion

                }

                get
                {
                    Context.Create();


                    var sql = "select ValueInt32 from ";
                    sql += Context.Name;
                    sql += " where Key = ";
                    sql += "'";
                    sql += Key;
                    sql += "'";

                    //new SQLiteCommand(sql, Connection).ExecuteScalar();

                    var value = 0;
                    var reader = new SQLiteCommand(sql, Context.Connection).ExecuteReader();

                    if (reader.Read())
                    {
                        value = reader.GetInt32(0);
                    }
                    reader.Close();

                    return value;
                }
            }
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:68,代码来源:SQLite.cs

示例4: SQLiteTableExists

        public static bool SQLiteTableExists(this SQLiteConnection c, string name)
        {
            var w = "select name from sqlite_master where type='table' and name=";
            w += "'";
            w += name;
            w += "'";


            var reader = new SQLiteCommand(w, c).ExecuteReader();

            var value = reader.Read();

            reader.Close();

            return value;
        }
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:16,代码来源:SQLite.cs

示例5: SQLiteCountByColumnName

        public static int SQLiteCountByColumnName(this SQLiteConnection Connection, string Name, string ByColumnName, string ValueString)
        {
            var sql = "select count(*) from ";
            sql += Name;
            sql += " where ";
            sql += ByColumnName;
            sql += " = ";
            sql += "'";
            sql += ValueString;
            sql += "'";

            var value = 0;
            var reader = new SQLiteCommand(sql, Connection).ExecuteReader();

            if (reader.Read())
            {
                value = reader.GetInt32(0);
            }

            reader.Close();

            return value;
        }
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:23,代码来源:SQLite.cs

示例6: values

            public Point this[string id]
            {
                set
                {
                    Context.Create();

                    if (Context.Connection.SQLiteCountByColumnName(Context.Name, "id", id) == 0)
                    {
                        var sql = "insert into ";
                        sql += Context.Name;
                        sql += " (id, x, y) values (";
                        sql += "'";
                        sql += id;
                        sql += "'";
                        sql += ", ";
                        sql += "'";
                        sql += value.x;
                        sql += "'";

                        sql += ", ";
                        sql += "'";
                        sql += value.y;
                        sql += "'";

                        sql += ")";



                        new SQLiteCommand(sql, Context.Connection).ExecuteNonQuery();

                        return;
                    }

                    #region update
                    {
                        var sql = "update ";
                        sql += Context.Name;

                        sql += " set x = ";
                        sql += "'";
                        sql += value.x;
                        sql += "'";

                        sql += " set y = ";
                        sql += "'";
                        sql += value.y;
                        sql += "'";


                        sql += " where id = ";
                        sql += "'";
                        sql += id;
                        sql += "'";

                        new SQLiteCommand(sql, Context.Connection).ExecuteNonQuery();
                    }
                    #endregion

                }

                get
                {
                    Context.Create();


                    var sql = "select x, y from ";
                    sql += Context.Name;
                    sql += " where id = ";
                    sql += "'";
                    sql += id;
                    sql += "'";

                    //new SQLiteCommand(sql, Connection).ExecuteScalar();

                    var value = default(Point);
                    var reader = new SQLiteCommand(sql, Context.Connection).ExecuteReader();

                    if (reader.Read())
                    {
                        value = new Point { x = reader.GetString(0), y = reader.GetString(1) };
                    }
                    reader.Close();

                    return value;
                }
            }
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:86,代码来源:InternalSQLiteKeyValueGenericTable.cs

示例7: SQLiteTableExists

        public static bool SQLiteTableExists(this SQLiteConnection c, string name)
        {
            // http://www.electrictoolbox.com/check-if-mysql-table-exists/



            //var w = "select name from sqlite_master where type='table' and name=";
            var w = "select table_name from information_schema.tables where table_name=";
            w += "'";
            w += name;
            w += "'";


            var reader = new SQLiteCommand(w, c).ExecuteReader();

            var value = reader.Read();

            reader.Close();

            return value;
        }
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:21,代码来源:InternalSQLiteKeyValueGenericTable.cs

示例8: GetKeys

        public List<string> GetKeys()
        {
            var sql = "select id from ";
            sql += Name;

            var value = new List<string>();

            var reader = new SQLiteCommand(sql, Connection).ExecuteReader();

            while (reader.Read())
            {
                value.Add(reader.GetString(0));
            }

            reader.Close();

            return value;
        }
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:18,代码来源:InternalSQLiteKeyValueGenericTable.cs

示例9: GetUserWorkStart

        public DateTime GetUserWorkStart(DateTimeOffset date)
        {
            var firstEntryDateTime = DateTime.Now; // default value
            try
            {
                var firstEntryReader = new SQLiteCommand("SELECT time FROM " + Settings.WindowsActivityTable +
                                                         " WHERE STRFTIME('%s', DATE(time))==STRFTIME('%s', DATE('" + date.Date.ToString("u") + "'))" +
                                                         " AND STRFTIME('%H', TIME(time)) >= STRFTIME('%H', TIME('04:00:00'))" + // day start should be after 04 am
                                                         " AND process != '" + Dict.Idle +
                                                         "' ORDER BY time ASC LIMIT 1;", _connection).ExecuteReader();

                if (firstEntryReader.HasRows)
                {
                    firstEntryReader.Read(); // read only once
                    firstEntryDateTime = DateTime.Parse((string)firstEntryReader["time"]);
                }

                firstEntryReader.Close();
            }
            catch (Exception e)
            {
                LogError(e.Message);
            }
            return firstEntryDateTime;
        }
开发者ID:sealuzh,项目名称:PersonalAnalytics,代码行数:25,代码来源:DatabaseImplementation.cs

示例10: GetUserWorkEnd

        public DateTime GetUserWorkEnd(DateTimeOffset date)
        {
            var lastEntryDateTime = DateTime.Now;
            try
            {
                var lastEntryReader = new SQLiteCommand("SELECT time FROM " + Settings.WindowsActivityTable +
                                                        " WHERE STRFTIME('%s', DATE(time))==STRFTIME('%s', DATE('" +
                                                        date.Date.ToString("u") + "'))" +
                                                        " AND process != '" + Dict.Idle + "' ORDER BY time DESC LIMIT 1;",
                    _connection).ExecuteReader();

                if (lastEntryReader.HasRows)
                {

                    lastEntryReader.Read(); // read only once
                    lastEntryDateTime = DateTime.Parse((string)lastEntryReader["time"]);
                }

                lastEntryReader.Close();
            }
            catch (Exception e)
            {
                LogError(e.Message);
            }
            return lastEntryDateTime;
        }
开发者ID:sealuzh,项目名称:PersonalAnalytics,代码行数:26,代码来源:DatabaseImplementation.cs

示例11: GetLastTimeZoneEntry

 public TimeZoneInfo GetLastTimeZoneEntry()
 {
     try
     {
         var reader = new SQLiteCommand("SELECT timezone FROM " + Settings.TimeZoneTable + " ORDER BY time DESC LIMIT 1;", _connection).ExecuteReader();
         if (reader.HasRows)
         {
             reader.Read(); // read only once
             var timeZone = TimeZoneInfo.FindSystemTimeZoneById((string)reader["timezone"]);
             return timeZone;
         }
         reader.Close();
         return null; // no entry or failed to parse
     }
     catch (Exception e)
     {
         LogError(e.Message);
         return null; // other error
     }
 }
开发者ID:sealuzh,项目名称:PersonalAnalytics,代码行数:20,代码来源:DatabaseImplementation.cs

示例12: ExecuteReader

        /// <summary>
        ///  Run a query against the Database.
        /// </summary>
        /// <param name="sql">The SQL to run</param>
        /// <returns>A DataTable containing the result set.</returns>
        public DataTable ExecuteReader(string sql)
        {
            SQLiteConnection connection = new SQLiteConnection(connectionString);
              try
              {
            connection.Open();

            var reader = new SQLiteCommand(connection)
            {
              CommandText = sql
            }.ExecuteReader();

            var dataTable = new DataTable();
            dataTable.Load(reader);

            reader.Close();

            return (dataTable);
              }
              catch (Exception e)
              {
            throw new Exception(e.Message);
              }
              finally
              {
            connection.Close();
              }
        }
开发者ID:haivido,项目名称:Vido,代码行数:33,代码来源:SQLiteDatabase.cs


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