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


C# SqliteConnection.Dispose方法代码示例

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


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

示例1: LoadLogImages

        public override bool LoadLogImages(List<Framework.Data.LogImage> logimgs)
        {
            bool result = false;
            SqliteConnection dbcon = new SqliteConnection(string.Format("data source=file:{0}", Properties.Settings.Default.ActiveDataFile));
            if (dbcon != null && InitDatabase(dbcon))
            {
                int logimgCount = 0;
                using (SqliteCommand cmd = new SqliteCommand("select logimage from counter", dbcon))
                using (SqliteDataReader dr = cmd.ExecuteReader())
                    if (dr.Read())
                    {
                        logimgCount = (int)dr["logimage"];
                    }

                int index = 0;
                int procStep = 0;
                using (SqliteCommand cmd = new SqliteCommand("select * from logimage", dbcon))
                using (SqliteDataReader dr = cmd.ExecuteReader())
                    while (dr.Read())
                    {
                        Framework.Data.LogImage lg = new Framework.Data.LogImage();

                        lg.ID = (string)dr["id"];
                        lg.LogID = (string)dr["logid"];
                        lg.Url = (string)dr["url"];
                        lg.Name = (string)dr["name"];
                        lg.DataFromDate = DateTime.Parse((string)dr["datafromdate"]).ToLocalTime();

                        lg.Saved = true;
                        lg.IsDataChanged = false;

                        _logimgsInDB[lg.ID] = lg.ID;
                        logimgs.Add(lg);

                        index++;
                        procStep++;
                        if (procStep >= 2000)
                        {
                            UpdateLoadingInBackgroundProgress(STR_LOADING_LOGIMAGES_BG, logimgCount, index);
                            procStep = 0;
                        }
                    }

                dbcon.Dispose();
                dbcon = null;
            }
            return result;
        }
开发者ID:RH-Code,项目名称:GAPP,代码行数:48,代码来源:InternalStorage.cs

示例2: LoadLogs

        public override bool LoadLogs(List<Framework.Data.Log> logs)
        {
            bool result = false;
            SqliteConnection dbcon = new SqliteConnection(string.Format("data source=file:{0}", Properties.Settings.Default.ActiveDataFile));
            if (dbcon != null && InitDatabase(dbcon))
            {
                int logCount = 0;
                using (SqliteCommand cmd = new SqliteCommand("select log from counter", dbcon))
                using (SqliteDataReader dr = cmd.ExecuteReader())
                    if (dr.Read())
                    {
                        logCount = (int)dr["log"];
                    }
                UpdateLoadingInBackgroundProgress(STR_LOADING_LOGS_BG, logCount, 0);

                int index = 0;
                int procStep = 0;
                using (SqliteCommand cmd = new SqliteCommand("select ID, gccode, Finder, DataFromDate, LogType, Date from log", dbcon))
                {
                    cmd.CommandTimeout = 0;
                    using (SqliteDataReader dr = cmd.ExecuteReader())
                        while (dr.Read())
                        {
                            Framework.Data.Log lg = new Framework.Data.Log();

                            lg.ID = (string)dr["id"];
                            lg.GeocacheCode = (string)dr["gccode"];
                            lg.Date = DateTime.Parse((string)dr["date"]).ToLocalTime();
                            lg.Finder = (string)dr["finder"];
                            lg.DataFromDate = DateTime.Parse((string)dr["datafromdate"]).ToLocalTime();
                            lg.LogType = Utils.DataAccess.GetLogType(Core.LogTypes, (int)(int)dr["logtype"]);

                            lg.Saved = true;
                            lg.IsDataChanged = false;

                            _logsInDB[lg.ID] = lg.ID;
                            logs.Add(lg);

                            index++;
                            procStep++;
                            if (procStep >= 20000)
                            {
                                UpdateLoadingInBackgroundProgress(STR_LOADING_LOGS_BG, logCount, index);
                                procStep = 0;
                            }
                        }
                }
                dbcon.Dispose();
                dbcon = null;
            }
            return result;
        }
开发者ID:RH-Code,项目名称:GAPP,代码行数:52,代码来源:InternalStorage.cs

示例3: LoadWaypoints

        public override bool LoadWaypoints(List<Framework.Data.Waypoint> wps, List<Framework.Data.UserWaypoint> usrwps)
        {
            bool result = false;
            SqliteConnection dbcon = new SqliteConnection(string.Format("data source=file:{0}", Properties.Settings.Default.ActiveDataFile));
            if (dbcon != null && InitDatabase(dbcon))
            {
                int wptCount = 0;
                using (SqliteCommand cmd = new SqliteCommand("select waypoint from counter", dbcon))
                using (SqliteDataReader dr = cmd.ExecuteReader())
                    if (dr.Read())
                    {
                        wptCount = (int)dr["waypoint"];
                    }

                int index = 0;
                int procStep = 0;
                using (SqliteCommand cmd = new SqliteCommand("select * from waypoint", dbcon))
                {
                    cmd.CommandTimeout = 0;
                    using (SqliteDataReader dr = cmd.ExecuteReader())
                        while (dr.Read())
                        {
                            Framework.Data.Waypoint wp = new Framework.Data.Waypoint();

                            wp.ID = (string)dr["id"];
                            wp.Code = (string)dr["code"];
                            wp.Url = (string)dr["url"];
                            wp.UrlName = (string)dr["urlname"];
                            wp.Name = (string)dr["name"];
                            wp.DataFromDate = DateTime.Parse((string)dr["datafromdate"]).ToLocalTime();
                            wp.Comment = (string)dr["comment"];
                            wp.GeocacheCode = (string)dr["geocachecode"];
                            wp.Description = (string)dr["description"];
                            wp.WPType = Utils.DataAccess.GetWaypointType(Core.WaypointTypes, (int)(int)dr["wptype"]);
                            object o = dr["lat"];
                            if (o == null || o.GetType() == typeof(DBNull))
                            {
                                wp.Lat = null;
                            }
                            else
                            {
                                wp.Lat = (double?)o;
                            }
                            o = dr["lon"];
                            if (o == null || o.GetType() == typeof(DBNull))
                            {
                                wp.Lon = null;
                            }
                            else
                            {
                                wp.Lon = (double?)o;
                            }
                            wp.Time = DateTime.Parse((string)dr["time"]).ToLocalTime();

                            wp.Saved = true;
                            wp.IsDataChanged = false;

                            _wptsInDB[wp.Code] = wp.Code;
                            wps.Add(wp);

                            index++;
                            procStep++;
                            if (procStep >= 20000)
                            {
                                UpdateLoadingInBackgroundProgress(STR_LOADING_WAYPOINTS_BG, wptCount, index);
                                procStep = 0;
                            }
                        }
                }
                using (SqliteCommand cmd = new SqliteCommand("select * from userwaypoint", dbcon))
                {
                    cmd.CommandTimeout = 0;
                    using (SqliteDataReader dr = cmd.ExecuteReader())
                        while (dr.Read())
                        {
                            Framework.Data.UserWaypoint wp = new Framework.Data.UserWaypoint();

                            wp.ID = (int)(int)dr["id"];
                            wp.GeocacheCode = (string)dr["geocachecode"];
                            wp.Description = (string)dr["description"];
                            wp.Lat = (double)dr["lat"];
                            wp.Lon = (double)dr["lon"];
                            wp.Date = DateTime.Parse((string)dr["time"]).ToLocalTime();

                            wp.Saved = true;
                            wp.IsDataChanged = false;

                            _usrwptsInDB[wp.ID] = wp.ID;
                            usrwps.Add(wp);
                        }
                }

                dbcon.Dispose();
                dbcon = null;
            }
            return result;
        }
开发者ID:RH-Code,项目名称:GAPP,代码行数:97,代码来源:InternalStorage.cs

示例4: Issue_65

    public void Issue_65()
    {
      //alxwest: causes error "Unable to open database" as TempDirectory.ToString() is set to "B:/TEMP/"
      //string datasource = "file://" + TempDirectory.ToString() + "myBigDb.s3db";
      string datasource = "file://" + "myBigDb.s3db";

      using (IDbConnection conn = new SqliteConnection("uri=" + datasource))
      {
        long targetFileSize = (long)Math.Pow(2, 32) - 1;
        int rowLength = 1024; // 2^10

        long loopCount = (int)(targetFileSize / rowLength) + 10000;

        char[] chars = new char[rowLength];
        for (int i = 0; i < rowLength; i++)
        {
          chars[i] = 'A';
        }

        string row = new string(chars);

        conn.Open();
        IDbCommand cmd = conn.CreateCommand();

        try
        {
          cmd.CommandText = "PRAGMA cache_size = 16000; PRAGMA synchronous = OFF; PRAGMA journal_mode = MEMORY;";
          cmd.ExecuteNonQuery();

          cmd.CommandText = "drop table if exists [MyTable]";
          cmd.ExecuteNonQuery();

          cmd.CommandText = "create table [MyTable] ([MyField] varchar(" + rowLength + ") null)";
          cmd.ExecuteNonQuery();

          cmd.CommandText = "insert into [MyTable] ([MyField]) VALUES ('" + row + "')";
          for (int i = 0; i < loopCount; i++)
          {
            cmd.ExecuteNonQuery();
          }
        }
        catch
        {
          Console.WriteLine(((SqliteCommand)cmd).GetLastError());
        }
        finally
        {
          cmd.Cancel();
          conn.Close();
          conn.Dispose();
        }
      }

    }
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:54,代码来源:SQLiteClientTestDriver.cs


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