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


C# SQLiteConnection.Dispose方法代码示例

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


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

示例1: CloseCon

        public static void CloseCon(SQLiteConnection con)
        {
            con.Close();
            con.Dispose();

            GC.Collect();
        }
开发者ID:oldfox94,项目名称:TPDev.DatabaseFactory,代码行数:7,代码来源:CONNECTION.cs

示例2: Steal_a_Feel

        public Steal_a_Feel(ref GeniePlugin.Interfaces.IHost host, string sDBLocation)
        {
            InitializeComponent();
            try
            {
                oDS = new DataSet();
                sSQLConn = new SQLiteConnection();

                oDS.Tables.Add("AllData");
                _host = host;

                _host.EchoText(sDBLocation);
                this.tbContainer.Text = this._host.get_Variable("StealingContainer");
                this.cbMark.Checked = this._host.get_Variable("StealingMark") == String.Empty ? false : true;
                this.cbPerceiveHealth.Checked = this._host.get_Variable("StealingPerceiveHealth") == String.Empty ? false : true;
                this.cbPerceive.Checked = this._host.get_Variable("StealingPerceive") == String.Empty ? false : true;
                this.sSQLConn.ConnectionString = "DataSource= " + sDBLocation;
                SQLiteCommand cmd = new SQLiteCommand(sSQLConn);
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = "select * from ItemList";
                SQLiteDataAdapter sDA = new SQLiteDataAdapter(cmd);
                sSQLConn.Open();
                DataSet ds = new DataSet();
                sDA.Fill(ds.Tables["AllData"]);
                sSQLConn.Close();
                sSQLConn.Dispose();
                cmd.Dispose();

                this.comboBox1.DataSource = oDS.Tables[0].Rows[1];
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
开发者ID:monil5100,项目名称:genie-stealing-plugin,代码行数:35,代码来源:Steal+a+Feel.cs

示例3: Connect

        public static void Connect()
        {
            try
            {
                SQLiteConnection SConnection = new SQLiteConnection();
                SConnection.ConnectionString =
                    "Data Source=users.siu;"  +
                    "UseUTF16Encoding=True;"  +
                    "Legacy Format=False;";

                SConnection.Open();

                CreatePlayersTable(SConnection);
                CreateBannersTable(SConnection);
                CreateMessagesTable(SConnection);
                CreateSquadsTable(SConnection);
                SiusLog.Log(SiusLog.DEBUG, "SQLite", "Attempted to create all necessary database tables.");

                SConnection.Close();
                SConnection.Dispose();
            }
            catch (Exception e)
            {
                SiusLog.Log(SiusLog.ERROR, "SQLite", e.Message);
            }
        }
开发者ID:ZacharyRead,项目名称:sius-biller,代码行数:26,代码来源:SQLite.cs

示例4: ExecuteDataSet

        public static DataSet ExecuteDataSet(string SqlRequest, SQLiteConnection Connection)
        {
            DataSet dataSet = new DataSet();
            dataSet.Reset();

            SQLiteCommand cmd = new SQLiteCommand(SqlRequest, Connection);
            try
            {
                Connection.Open();
                SQLiteDataAdapter dataAdapter = new SQLiteDataAdapter(cmd);
                dataAdapter.Fill(dataSet);
            }
            catch (SQLiteException ex)
            {
                Log.Write(ex);
                //Debug.WriteLine(ex.Message);
                throw; // пересылаем исключение на более высокий уровень
            }
            finally
            {
                Connection.Dispose();
            }

            return dataSet;
        }
开发者ID:alexrigin,项目名称:HMS2,代码行数:25,代码来源:DBManager.cs

示例5: GetDataTable

 public DataTable GetDataTable(string strSQL, string TableName)
 {
     DataTable dt = null;
     try
     {
         using (SQLiteConnection scon = new SQLiteConnection(DataAccessUtilities.CreateSQLiteConnectionString()))
         {
             scon.Open();
             SQLiteCommand com = new SQLiteCommand(strSQL, scon);
             using (SQLiteDataReader dr = com.ExecuteReader())
             {
                 dt = new DataTable(TableName);
                 dt.Load(dr);
                 dr.Close();
             }
             com.Dispose();
             scon.Close();
             scon.Dispose();
         }
     } 
     catch (Exception ex)
     {
         LogManager.Instance.LogMessage("Error in GetDataTable", ex);
     }
     return dt;
 }
开发者ID:Nsobi,项目名称:PoliceReports,代码行数:26,代码来源:ClientDataAccess.cs

示例6: GetLoginAuths

        /// <summary>
        /// 获得本地保存的用户登录认证信息
        /// </summary>
        /// <returns></returns>
        public static List<Auth> GetLoginAuths()
        {
            List<Auth> auths = null;

            string sql = "select * from log order by updateTime desc";
            string constr ="data source="+Application.StartupPath +"\\login"+".db";

            SQLiteConnection con = new SQLiteConnection(constr);
            con.Open();
            SQLiteCommand cmd = new SQLiteCommand(sql);
            cmd.Connection = con;
            SQLiteDataReader dr = cmd.ExecuteReader();
            if (dr != null)
            {
                auths = new List<Auth>();
                while (dr.Read())
                {
                    Auth a =Factory.CreateInstanceObject(dr["auth"].ToString()) as Auth  ;
                    if (a != null)
                        auths.Add(a);
                }
                dr.Close();
            }
            dr.Dispose(); dr = null;
            cmd.Dispose(); cmd = null; 
            con.Close();con.Dispose(); con = null;

            return auths;
        }
开发者ID:iraychen,项目名称:ourmsg,代码行数:33,代码来源:OpeRecordDB.cs

示例7: Main

        public static void Main(string[] args)
        {

            #region QueryExpressionBuilder.WithConnection
            ScriptCoreLib.Query.Experimental.QueryExpressionBuilder.WithConnection =
                y =>
                {
                    // jsc should imply it?

                    var cc = new SQLiteConnection(
                        new SQLiteConnectionStringBuilder
                    {
                        DataSource = "file:Book1.xlsx.sqlite"
                    }.ToString()
                    );

                    cc.Open();
                    y(cc);
                    cc.Dispose();
                };
            #endregion

            new ApplicationWebService().WebMethod2("", delegate { });


            RewriteToUltraApplication.AsProgram.Launch(typeof(Application));
        }
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:27,代码来源:Program.cs

示例8: Form1

        public Form1()
        {

            SQLiteConnection connection = new SQLiteConnection();
            connection.Open();

            if (!isInitialized)
            {
                InitDatabase(connection);
            }
            LoadDatabase(connection);
            connection.Dispose();


            InitializeComponent();
            sepLabel1.AutoSize = sepLabel2.AutoSize = sepLabel3.AutoSize = false;
            sepLabel1.Height = sepLabel2.Height = sepLabel3.Height = 2;
            sepLabel1.Width = sepLabel2.Width = sepLabel3.Width = 529 - 6;
            sepLabel1.BorderStyle = sepLabel2.BorderStyle = sepLabel3.BorderStyle = BorderStyle.Fixed3D;



            Disciple1_1.DataSource = Disciple.GetNames();
            Disciple1_2.DataSource = Disciple.GetNames();
            Disciple1_3.DataSource = Disciple.GetNames();
            Disciple2_1.DataSource = Disciple.GetNames();
            Disciple2_2.DataSource = Disciple.GetNames();
            Disciple2_3.DataSource = Disciple.GetNames();
            Disciple3_1.DataSource = Disciple.GetNames();
            Disciple3_2.DataSource = Disciple.GetNames();
            Disciple3_3.DataSource = Disciple.GetNames();

            
        }
开发者ID:szyuGH,项目名称:playground,代码行数:34,代码来源:Form1.cs

示例9: GetSqliteData

    /// <summary>
    /// Generic Method to return data from sqlite database type
    /// </summary>
    /// <param name="connStr"></param>
    /// <param name="sql"></param>
    /// <returns></returns>
    public static DataSet GetSqliteData(string connStr, string sql)
    {
        DataSet ds = new DataSet();

        using (SQLiteConnection conn = new SQLiteConnection(connStr))
        {
            conn.Open();

            SQLiteDataAdapter da = new SQLiteDataAdapter(sql, conn);

            try
            {
                da.Fill(ds);
            }
            catch (Exception)
            {
                ds = new DataSet();
            }
            finally
            {
                da.Dispose();

                conn.Close();
                conn.Dispose();
            }
        }

        return ds;
    }
开发者ID:nelsonjma,项目名称:ntec,代码行数:35,代码来源:generic.cs

示例10: Cleanup

    private void Cleanup(SQLiteConnection cnn)
    {
      if (_disposeConnection)
        cnn.Dispose();

      _transaction = null;
      _scope = null;
    }
开发者ID:AugustoAngeletti,项目名称:blockspaces,代码行数:8,代码来源:SQLiteEnlistment.cs

示例11: Cleanup

        private void Cleanup(SQLiteConnection conn)
        {
            CurrentTransaction = null;

            conn.Close();
            conn.Dispose();

            _complete = true;
        }
开发者ID:TimCollins,项目名称:BlogEngine,代码行数:9,代码来源:DbTransaction.cs

示例12: CloseConnection

 /// <summary>
 /// 关闭一个数据库连接
 /// </summary>
 /// <param name="conn"></param>
 public static void CloseConnection(SQLiteConnection conn)
 {
     if (conn.State.ToString().ToLower() == "open")
     {
         //如果连接状态为打开
         conn.Close();//关闭连接
         conn.Dispose();//释放内存
     }
 }
开发者ID:gerrywang,项目名称:gerrygit,代码行数:13,代码来源:DbAccess.cs

示例13: Main

    static void Main(string[] args)
    {
        // X:\jsc.svn\examples\javascript\LINQ\ClickCounter\ClickCounter\Application.cs
        // X:\jsc.svn\examples\javascript\LINQ\LINQWebCamAvatars\LINQWebCamAvatars\Application.cs
        // string DataSource = "file:PerformanceResourceTimingData2.xlsx.sqlite"

        #region QueryExpressionBuilder.WithConnection
        QueryExpressionBuilder.WithConnection =
            y =>
            {
                var cc = new SQLiteConnection(
                    new SQLiteConnectionStringBuilder { DataSource = "file:PerformanceResourceTimingData2.xlsx.sqlite" }.ToString()
                );

                cc.Open();
                y(cc);
                cc.Dispose();
            };
        #endregion

        // ThreadLocal SynchronizationContext aware ConnectionPool?
        var n = new PerformanceResourceTimingData2ApplicationPerformance();

        //n.Create();

        n.Insert(
            new PerformanceResourceTimingData2ApplicationPerformanceRow
        {
            connectStart = 5,
            connectEnd = 13,
            EventTime = DateTime.Now.AddDays(-0),

            z = new XElement("goo", "foo")
        }
        );

        //var c = new PerformanceResourceTimingData2ApplicationPerformance().Count();


        // /* 2102:0007 */     /* let */ `PerformanceResourceTimingData2ApplicationPerformance`.`Key` as /* x */ `Key`

        var q = from x in new PerformanceResourceTimingData2ApplicationPerformance()
                orderby x.Timestamp descending
                select new[] { x.z };


        var f = q.FirstOrDefault();

        Console.WriteLine(new { f });

        //new xApplicationPerformance().Where(x => x.Key == f.Key).Delete();
        //new PerformanceResourceTimingData2ApplicationPerformance().Delete(x => x.Key == f.Key);



    }
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:56,代码来源:Program.cs

示例14: DisposeConnection

 public static void DisposeConnection(SQLiteConnection conn)
 {
     if(conn.State.Equals("Open"))
     {
         conn.Close();
         conn.Dispose();
         conn = null;
         GC.Collect();
     }
 }
开发者ID:ErikHage,项目名称:HabitatTracker,代码行数:10,代码来源:SQLiteConnectionFactory.cs

示例15: AddConnectionIfNeeded

 public void AddConnectionIfNeeded(IConnectionInformation connection)
 {
     var fileName = GetFileNameFromConnectionString.GetFileName(connection.ConnectionString);
     if (!fileName.IsInMemory) return;
     if (_connections.ContainsKey(connection.ConnectionString)) return;
     var sqlConnection = new SQLiteConnection(connection.ConnectionString);
     try
     {
         sqlConnection.Open();
     }
     catch (Exception) //resource leak possible on open
     {
         sqlConnection.Dispose();
         throw;
     }
     if (!_connections.TryAdd(connection.ConnectionString, sqlConnection))
     {
         //already added by another thread
         sqlConnection.Dispose();
     }
 }
开发者ID:blehnen,项目名称:DotNetWorkQueue,代码行数:21,代码来源:SqLiteHoldConnection.cs


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