本文整理汇总了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();
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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));
}
示例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();
}
示例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;
}
示例10: Cleanup
private void Cleanup(SQLiteConnection cnn)
{
if (_disposeConnection)
cnn.Dispose();
_transaction = null;
_scope = null;
}
示例11: Cleanup
private void Cleanup(SQLiteConnection conn)
{
CurrentTransaction = null;
conn.Close();
conn.Dispose();
_complete = true;
}
示例12: CloseConnection
/// <summary>
/// 关闭一个数据库连接
/// </summary>
/// <param name="conn"></param>
public static void CloseConnection(SQLiteConnection conn)
{
if (conn.State.ToString().ToLower() == "open")
{
//如果连接状态为打开
conn.Close();//关闭连接
conn.Dispose();//释放内存
}
}
示例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);
}
示例14: DisposeConnection
public static void DisposeConnection(SQLiteConnection conn)
{
if(conn.State.Equals("Open"))
{
conn.Close();
conn.Dispose();
conn = null;
GC.Collect();
}
}
示例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();
}
}