本文整理汇总了C#中SqliteConnection类的典型用法代码示例。如果您正苦于以下问题:C# SqliteConnection类的具体用法?C# SqliteConnection怎么用?C# SqliteConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SqliteConnection类属于命名空间,在下文中一共展示了SqliteConnection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnIN_Click
/// <summary>
/// Добавя категория
/// </summary>
private void btnIN_Click(object sender, EventArgs e)
{
if ((cbTNCategoriesSub.SelectedValue == null)
|| cbTNCategoriesSub.SelectedValue.ToString().Equals(""))
{ return; }
if (dgvCatOUT.CurrentRow == null)
{ return; }
Int32 iCategoryID = Convert.ToInt32(dgvCatOUT.CurrentRow.Cells["gcCategoryID_OUT"].Value);
try
{
using (SqliteConnection sqlCnnctn = new SqliteConnection())
{
sqlCnnctn.ConnectionString = _ConnectionString;
sqlCnnctn.Open();
using (SqliteCommand sqlCmmnd = new SqliteCommand())
{
sqlCmmnd.Connection = sqlCnnctn;
sqlCmmnd.CommandText =
"UPDATE x_news_nweb " +
" SET nweb_category_id = " + cbTNCategoriesSub.SelectedValue.ToString() +
" WHERE news_category_id = " + iCategoryID.ToString();
sqlCmmnd.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
cbTNCategoriesSub_SelectedIndexChanged(null, null);
}
示例2: Initialise
public void Initialise(string connectionString)
{
if (Util.IsWindows())
Util.LoadArchSpecificWindowsDll("sqlite3.dll");
m_connectionString = connectionString;
m_log.Info("[ESTATE DB]: Sqlite - connecting: "+m_connectionString);
m_connection = new SqliteConnection(m_connectionString);
m_connection.Open();
Migration m = new Migration(m_connection, Assembly, "EstateStore");
m.Update();
//m_connection.Close();
// m_connection.Open();
Type t = typeof(EstateSettings);
m_Fields = t.GetFields(BindingFlags.NonPublic |
BindingFlags.Instance |
BindingFlags.DeclaredOnly);
foreach (FieldInfo f in m_Fields)
if (f.Name.Substring(0, 2) == "m_")
m_FieldMap[f.Name.Substring(2)] = f;
}
示例3: Initialise
public void Initialise(string connectionString)
{
m_connectionString = connectionString;
m_log.Info("[ESTATE DB]: Sqlite - connecting: "+m_connectionString);
m_connection = new SqliteConnection(m_connectionString);
try
{
m_connection.Open();
}
catch (Exception ex)
{
throw new Exception("SQLite has errored out on opening the database. If you are on a 64 bit system, please run OpenSim.32BitLaunch.exe and try again. If this is not a 64 bit error :" + ex);
}
Assembly assem = GetType().Assembly;
Migration m = new Migration(m_connection, assem, "EstateStore");
m.Update();
//m_connection.Close();
// m_connection.Open();
Type t = typeof(EstateSettings);
m_Fields = t.GetFields(BindingFlags.NonPublic |
BindingFlags.Instance |
BindingFlags.DeclaredOnly);
foreach (FieldInfo f in m_Fields)
if (f.Name.Substring(0, 2) == "m_")
m_FieldMap[f.Name.Substring(2)] = f;
}
示例4: Initialise
public void Initialise(string connectionString)
{
m_connectionString = connectionString;
m_log.Info("[ESTATE DB]: Sqlite - connecting: "+m_connectionString);
m_connection = new SqliteConnection(m_connectionString);
m_connection.Open();
Assembly assem = GetType().Assembly;
Migration m = new Migration(m_connection, assem, "EstateStore");
m.Update();
//m_connection.Close();
// m_connection.Open();
Type t = typeof(EstateSettings);
m_Fields = t.GetFields(BindingFlags.NonPublic |
BindingFlags.Instance |
BindingFlags.DeclaredOnly);
foreach (FieldInfo f in m_Fields)
if (f.Name.Substring(0, 2) == "m_")
m_FieldMap[f.Name.Substring(2)] = f;
}
示例5: QueryCache
public QueryCache(SqliteConnection connection)
{
this.updateCommands = new MappingCommandDictionary();
this.insertCommands = new InsertCommandDictionary();
this.cachedCommands = new CommandDictionary();
this.Connection = connection;
}
示例6: OpenConnection
public static SqliteConnection OpenConnection(string connectionString)
{
SqliteConnection connection = new SqliteConnection();
connection.ConnectionString = connectionString;
connection.Open();
return connection;
}
示例7: CreateCrypted
public void CreateCrypted(string databaseFile)
{
try
{
// Check if database already exists
if (!File.Exists (databaseFile))
{
// Create the database
SqliteConnection.CreateFile (databaseFile);
// Connect to the database
// using (SqliteConnection sqlCon = GetConnection (String.Format ("Data Source = {0};", databaseFile),"haluk"))
using (SqliteConnection sqlCon = new SqliteConnection (String.Format ("Data Source = {0}", databaseFile)))
{
sqlCon.SetPassword("haluk");
sqlCon.Open ();
// Create a table
using (SqliteCommand sqlCom = new SqliteCommand (sqlCon))
{
sqlCom.CommandText = "CREATE TABLE Personel (ID INTEGER PRIMARY KEY, UserName VARCHAR(20), Password VARCHAR(20))";
//veri Ekleme
//Update
// sqlCom.CommandText = "UPDATE Customers SET FirstName= 'Haluk' WHERE LastName = @lastName";
// sqlCom.Parameters.Add(new SqliteParameter("@lastName","Haluky"));
sqlCom.ExecuteNonQuery ();
Console.WriteLine(sqlCom.ExecuteNonQuery());
}
//end using sqlCom
sqlCon.Close ();
}
//end using sqlCon
this.durumGostericiT.Text = "Database hazır!";
}else
{
this.durumGostericiT.Text = "Database Mevcut!";
}//end if else
} catch (Exception ex)
{
this.durumGostericiT.Text = String.Format ("Sqlite error: {0}", ex.Message);
}//end try catch
}
示例8: Fill
public static int Fill(string commandText, SqliteConnection connection, DataTable dataTable)
{
int res = 0;
using (SqliteCommand command = new SqliteCommand())
{
command.Connection = connection;
command.CommandText = commandText;
using (SqliteDataAdapter sqlDAdapter = new SqliteDataAdapter(command))
{
res = sqlDAdapter.Fill(dataTable);
}
}
return res;
}
示例9: AssertConnectionOpens
private static void AssertConnectionOpens(string connectionString, string expectedPath)
{
if (File.Exists(expectedPath))
{
File.Delete(expectedPath);
}
using (var connection = new SqliteConnection(connectionString))
{
connection.Open();
Assert.Equal(expectedPath, connection.DataSource);
}
Assert.True(File.Exists(expectedPath));
}
示例10: Initialise
/// <summary>
/// <list type="bullet">
/// <item>Initialises AssetData interface</item>
/// <item>Loads and initialises a new SQLite connection and maintains it.</item>
/// <item>use default URI if connect string is empty.</item>
/// </list>
/// </summary>
/// <param name="dbconnect">connect string</param>
override public void Initialise(string dbconnect)
{
if (dbconnect == string.Empty)
{
dbconnect = "URI=file:Asset.db,version=3";
}
m_conn = new SqliteConnection(dbconnect);
m_conn.Open();
Assembly assem = GetType().Assembly;
Migration m = new Migration(m_conn, assem, "AssetStore");
m.Update();
return;
}
示例11: Initialise
public void Initialise(string connectionString)
{
if (Util.IsWindows())
Util.LoadArchSpecificWindowsDll("sqlite3.dll");
m_connectionString = connectionString;
m_log.Info("[PROFILES_DATA]: Sqlite - connecting: "+m_connectionString);
m_connection = new SqliteConnection(m_connectionString);
m_connection.Open();
Migration m = new Migration(m_connection, Assembly, "UserProfiles");
m.Update();
}
示例12: ExecuteReader
protected IDataReader ExecuteReader(SqliteCommand cmd, SqliteConnection connection)
{
lock (connection)
{
//SqliteConnection newConnection =
// (SqliteConnection)((ICloneable)connection).Clone();
//newConnection.Open();
//cmd.Connection = newConnection;
cmd.Connection = connection;
//Console.WriteLine("XXX " + cmd.CommandText);
return cmd.ExecuteReader();
}
}
示例13: SQLiteAuthenticationData
public SQLiteAuthenticationData(string connectionString, string realm)
: base(connectionString)
{
m_Realm = realm;
if (!m_initialized)
{
m_Connection = new SqliteConnection(connectionString);
m_Connection.Open();
Migration m = new Migration(m_Connection, Assembly, "AuthStore");
m.Update();
m_initialized = true;
}
}
示例14: LoadNews
public void LoadNews()
{
try
{
using (SqliteConnection sqlCnnctn = new SqliteConnection())
{
sqlCnnctn.ConnectionString = _ConnectionString;
sqlCnnctn.Open();
//
using (SqliteCommand sqlCmmndNews = new SqliteCommand())
{
using (SqliteCommand sqlCmmndEncl = new SqliteCommand())
{
sqlCmmndNews.Connection = sqlCnnctn;
sqlCmmndEncl.Connection = sqlCnnctn;
// сваля и зарежда новините
foreach (NewsSource ns in _PNews.NSource)
{
try
{
OnLog(LogMessageType.Event, ns.Title);
//
LoadNewsRSS(sqlCmmndNews, sqlCmmndEncl, ns);
//
OnLog(LogMessageType.Event, _PNews.WSaitID.ToString() + _Msg3_NewsChargedHandle);
TmpNewsRepair(sqlCmmndNews);
//
OnLog(LogMessageType.Event, _PNews.WSaitID.ToString() + _Msg4_LoadingNews);
TmpNewsTransfer(sqlCmmndNews, sqlCmmndEncl);
//
OnLog(LogMessageType.Event, _PNews.WSaitID.ToString() + _Msg5_Done);
}
catch (Exception ex)
{
OnLog(LogMessageType.Error, "Exception /Load:" + ns.URL + "/: " + ex.Message);
}
}
}
}
}
}
catch (Exception ex)
{
OnLog(LogMessageType.Error, "Exception: " + ex.Message);
}
}
示例15: ExecuteNonQuery
//////////////////////////////////////////////////////////////
//
// All non queries are funneled through one connection
// to increase performance a little
//
protected int ExecuteNonQuery(SqliteCommand cmd, SqliteConnection connection)
{
lock (connection)
{
/*
SqliteConnection newConnection =
(SqliteConnection)((ICloneable)connection).Clone();
newConnection.Open();
cmd.Connection = newConnection;
*/
cmd.Connection = connection;
//Console.WriteLine("XXX " + cmd.CommandText);
return cmd.ExecuteNonQuery();
}
}