本文整理汇总了C#中SqliteConnection.Close方法的典型用法代码示例。如果您正苦于以下问题:C# SqliteConnection.Close方法的具体用法?C# SqliteConnection.Close怎么用?C# SqliteConnection.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SqliteConnection
的用法示例。
在下文中一共展示了SqliteConnection.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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
}
示例2: btnDeleteInvalidEntries_Click
/// <summary>
/// Изтрива невалидни записи
/// </summary>
private void btnDeleteInvalidEntries_Click(object sender, EventArgs e)
{
try
{
listBox1.Items.Clear();
SetMessage("Старт: Изтрива невалидни записи");
using (SqliteConnection sqlCnnctn = new SqliteConnection())
{
sqlCnnctn.ConnectionString = _ConnectionString;
sqlCnnctn.Open();
using (SqliteCommand sqlCmmnd = new SqliteCommand())
{
sqlCmmnd.Connection = sqlCnnctn;
// Новини без картинки
sqlCmmnd.CommandText =
"DELETE FROM news " +
" WHERE news_id NOT IN (SELECT DISTINCT news_id FROM enclosure ) ";
Int32 iRows = sqlCmmnd.ExecuteNonQuery();
SetMessage("Изтити новини без картинки: " + iRows.ToString());
// Картинки без новини
sqlCmmnd.CommandText =
"DELETE FROM enclosure " +
" WHERE news_id NOT IN (SELECT news_id FROM news) ";
iRows = sqlCmmnd.ExecuteNonQuery();
SetMessage("Изтити картинки без новини: " + iRows.ToString());
}
sqlCnnctn.Close();
}
SetMessage("Край");
}
catch (Exception ex)
{
SetMessage(ex.Message);
}
}
示例3: SqList
public void SqList(string databaseFile,string opinion)
{
try
{
if (!File.Exists (databaseFile))
{
return;
}
//end if
// Connect to database
using (SqliteConnection sqlCon = new SqliteConnection (String.Format ("Data Source = {0}", databaseFile)))
{
sqlCon.SetPassword("haluk");
sqlCon.Open ();
using (SqliteCommand sqlCom = new SqliteCommand (sqlCon))
{
sqlCom.CommandText="SELECT * FROM Personel";
// if(opinion=="Z")
// sqlCom.CommandText = "SELECT * FROM ZSUBE";
//
// else if(opinion=="Y")
// sqlCom.CommandText = "SELECT * FROM YSUBE";
//
// Execute the SELECT statement and retrieve the data
using (SqliteDataReader dbReader = sqlCom.ExecuteReader ())
{
if (dbReader.HasRows)
{
int i;
// Advance through each row
tasks = new List<TaskX> ();
while (dbReader.Read ())
{
TaskX dtask= new TaskX() {Id = Convert.ToInt16( dbReader["ID"]),
Name = String.Format (Convert.ToString (dbReader["UserName"])),
Notes=String.Format ( Convert.ToString (dbReader["Password"])),
Done=false};
tasks.Add(dtask);
};
}
};
TableView.Source = new RootTableSource(tasks.ToArray ());
}
sqlCon.Close ();
}
} catch (Exception ex)
{ }
}
示例4: btn_Save_Click
private void btn_Save_Click(object sender, EventArgs e)
{
try
{
using (SqliteConnection sqlCnnctn = new SqliteConnection())
{
sqlCnnctn.ConnectionString = _ConnectionString;
sqlCnnctn.Open();
using (SqliteCommand sqlCmmnd = new SqliteCommand())
{
sqlCmmnd.Connection = sqlCnnctn;
sqlCmmnd.CommandText =
"UPDATE t_news_category " +
" SET n_dscr = @n_dscr " +
" WHERE news_category_id = " + _CatID.ToString();
sqlCmmnd.Parameters.Add("@n_dscr", DbType.String).Value = tbx_NDscr.Text.Trim();
using (SqliteDataReader sqlDReader = sqlCmmnd.ExecuteReader())
{
if (sqlDReader.HasRows && sqlDReader.Read())
{
lbl_NCategory.Text = sqlDReader["news_category"].ToString();
lbl_NSource.Text = sqlDReader["n_source"].ToString();
tbx_NDscr.Text = sqlDReader["n_dscr"].ToString();
}
sqlDReader.Close();
}
}
sqlCnnctn.Close();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return;
}
Close();
}
示例5: LoadData
private void LoadData()
{
lbl_ID.Text = _CatID.ToString();
using (SqliteConnection sqlCnnctn = new SqliteConnection())
{
sqlCnnctn.ConnectionString = _ConnectionString;
sqlCnnctn.Open();
using (SqliteCommand sqlCmmnd = new SqliteCommand())
{
sqlCmmnd.Connection = sqlCnnctn;
sqlCmmnd.CommandText =
"SELECT nct.news_category " +
" , ifnull(nct.n_dscr, '') AS n_dscr " +
" , src.n_source " +
" FROM t_news_category nct " +
" , t_news_sources src " +
" WHERE nct.news_category_id = " + _CatID.ToString() +
" AND src.n_source_id = nct.n_source_id ";
using (SqliteDataReader sqlDReader = sqlCmmnd.ExecuteReader())
{
if (sqlDReader.HasRows && sqlDReader.Read())
{
lbl_NCategory.Text = sqlDReader["news_category"].ToString();
lbl_NSource.Text = sqlDReader["n_source"].ToString();
tbx_NDscr.Text = sqlDReader["n_dscr"].ToString();
}
sqlDReader.Close();
}
}
sqlCnnctn.Close();
}
}
示例6: SelectData
public void SelectData(string databaseFile)
{
try
{
if (!File.Exists (databaseFile))
{
this.durumGostericiT.Text = "Database file does not exis using (SqliteConnection sqlCon = new SqliteConnection (String.Format (\"Data Source = {0}\", databaseFile))) \nt. Tap the appropriate button to create it.";
return;
}
//end if
// Connect to database
using (SqliteConnection sqlCon = new SqliteConnection (String.Format ("Data Source = {0}", databaseFile)))
{
sqlCon.SetPassword("haluk");
sqlCon.Open ();
using (SqliteCommand sqlCom = new SqliteCommand (sqlCon))
{
sqlCom.CommandText = "SELECT * FROM Personel WHERE Password = @lastName and UserName = @username";
sqlCom.Parameters.Add (new SqliteParameter ("@lastName", passwordF.Text));
sqlCom.Parameters.Add (new SqliteParameter ("@username", usernameF.Text));
// Execute the SELECT statement and retrieve the data
using (SqliteDataReader dbReader = sqlCom.ExecuteReader ())
{
if (dbReader.HasRows)
{
// Advance through each row
while (dbReader.Read ())
{
durumGostericiT.Text="eşlenme sağlandı";
this.usernameF.Text += String.Format ("ID: {0}\n", Convert.ToString (dbReader["UserName"]));
this.passwordF.Text += String.Format (" : {0}\n", Convert.ToString (dbReader["Password"]));
this.PerformSegue("GondericiC",this);
}
//end while
}
//end if
}//end using dbReader
}
//end using sqlCom
sqlCon.Close ();
}
//end using sqlCon
// this.durumGostericiT.Text += "Customer data retrieved.\n";
} catch (Exception ex)
{
this.durumGostericiT.Text = String.Format ("{0}", ex.Message);
}
//end try catch
}
示例7: InsertData
private void InsertData(string databaseFile)
{
try
{
if (!File.Exists (databaseFile))
{
this.durumGostericiT.Text = "Database file does not exist. Tap the appropriate button to create it.";
return;
}
//end if
// Connect to the database
using (SqliteConnection sqlCon = new SqliteConnection (String.Format ("Data Source = {0}", databaseFile)))
{
sqlCon.SetPassword("haluk");
sqlCon.Open ();
using (SqliteCommand sqlCom = new SqliteCommand (sqlCon))
{
sqlCom.CommandText = "INSERT INTO Personel (UserName, Password) VALUES (@username, @password)";
sqlCom.Parameters.Add (new SqliteParameter ("@username",usernameF.Text ));
sqlCom.Parameters.Add (new SqliteParameter ("@password", passwordF.Text));
sqlCom.ExecuteNonQuery ();
}
//end using sqlCom
sqlCon.Close ();
}
//end using sqlCon
this.durumGostericiT.Text = "Veri Girildi.";
} catch (Exception ex)
{
this.durumGostericiT.Text = String.Format ("Sqlite hatası: {0}", ex.Message);
}//end try catch
}
示例8: CreateXMLSubCategories
private void CreateXMLSubCategories()
{
SetMessage(LogMessageType.Event, "CreateXMLSubCategories: Start");
using (SqliteConnection sqlCnnctn = new SqliteConnection())
{
sqlCnnctn.ConnectionString = _ConnectionString;
sqlCnnctn.Open();
WriteXML_Subcategories(sqlCnnctn);
sqlCnnctn.Close();
}
SetMessage(LogMessageType.Event, "CreateXMLSubCategories: Done");
}
示例9: CreateXMLNews
/// <summary>
/// Създава XML файл за новите новини
/// </summary>
private void CreateXMLNews()
{
SetMessage(LogMessageType.Event, "CreateXMLNews: Start");
if (File.Exists(_ApplPath_NewsXML))
{
SetMessage(LogMessageType.Event, "CreateXMLNews: Има незаредени новини");
}
else
{
using (SqliteConnection sqlCnnctn = new SqliteConnection())
{
sqlCnnctn.ConnectionString = _ConnectionString;
sqlCnnctn.Open();
//
Int64 iLastSendNews = GetLastSendNews(sqlCnnctn);
//
WriteXML_News(sqlCnnctn, iLastSendNews);
WriteXML_NewsInfo(sqlCnnctn, iLastSendNews);
WriteXML_Enclosure(sqlCnnctn, iLastSendNews);
//
SetLastSendNews(sqlCnnctn);
//
sqlCnnctn.Close();
}
}
//
SetMessage(LogMessageType.Event, "CreateXMLNews: Done");
}
示例10: btnDeleteOldNews_Click
/// <summary>
/// Изтрива старите новини
/// </summary>
private void btnDeleteOldNews_Click(object sender, EventArgs e)
{
try
{
listBox1.Items.Clear();
SetMessage("Старт: Изтрива старите новини");
using (SqliteConnection sqlCnnctn = new SqliteConnection())
{
sqlCnnctn.ConnectionString = _ConnectionString;
sqlCnnctn.Open();
using (SqliteCommand sqlCmmnd = new SqliteCommand())
{
sqlCmmnd.Connection = sqlCnnctn;
sqlCmmnd.CommandText =
"DELETE FROM news " +
" WHERE news_pubdate < @FromDate ";
sqlCmmnd.Parameters.Clear();
sqlCmmnd.Parameters.Add("@FromDate", DbType.Date).Value = DateTime.Now.AddMonths(-1).AddDays(-1);
int iDelNews = sqlCmmnd.ExecuteNonQuery();
SetMessage("Delete News: " + iDelNews.ToString());
}
sqlCnnctn.Close();
}
SetMessage("Край");
}
catch (Exception ex)
{
SetMessage(ex.Message);
}
}
示例11: btn_Optimization_Click
/// <summary>
/// Оптимиьира базата
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_Optimization_Click(object sender, EventArgs e)
{
try
{
listBox1.Items.Clear();
SetMessage("Старт: Оптимизация");
using (SqliteConnection sqlCnnctn = new SqliteConnection())
{
sqlCnnctn.ConnectionString = _ConnectionString;
sqlCnnctn.Open();
using (SqliteCommand sqlCmmnd = new SqliteCommand())
{
sqlCmmnd.Connection = sqlCnnctn;
SetMessage("Старт: ReIndex");
sqlCmmnd.CommandText = "REINDEX;";
sqlCmmnd.ExecuteNonQuery();
SetMessage("Край: ReIndex");
SetMessage("Старт: Compact the database");
sqlCmmnd.CommandText = "VACUUM;";
sqlCmmnd.ExecuteNonQuery();
SetMessage("Край: Compact the database");
}
sqlCnnctn.Close();
}
SetMessage("Край: Оптимизация");
}
catch (Exception ex)
{
SetMessage(ex.Message);
}
}
示例12: btnOUT_Click
/// <summary>
/// Премахва категория
/// </summary>
private void btnOUT_Click(object sender, EventArgs e)
{
if (dgvCatIN.CurrentRow == null)
{ return; }
Int32 iCategoryID = Convert.ToInt32(dgvCatIN.CurrentRow.Cells["gcCategoryID_IN"].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 = -1 " +
" WHERE news_category_id = " + iCategoryID.ToString();
sqlCmmnd.ExecuteNonQuery();
}
sqlCnnctn.Close();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
cbTNCategoriesSub_SelectedIndexChanged(null, null);
}
示例13: UpdateData
private void UpdateData(string databaseFile)
{
try
{
if (!File.Exists (databaseFile))
{
return;
}
//end if
// Connect to database
using (SqliteConnection sqlCon = new SqliteConnection (String.Format ("Data Source = {0}", databaseFile)))
{
sqlCon.SetPassword("haluk");
sqlCon.Open ();
if(idX.Text=="")
{
using (SqliteCommand sqlCom = new SqliteCommand (sqlCon))
{
sqlCom.CommandText = "INSERT INTO Personel (UserName, Password) VALUES (@username, @password)";
sqlCom.Parameters.Add (new SqliteParameter ("@username",TitleText.Text ));
sqlCom.Parameters.Add (new SqliteParameter ("@password", NotesText.Text));
sqlCom.ExecuteNonQuery ();
}
}
if (idX.Text!=null)
{
using (SqliteCommand sqlCom = new SqliteCommand (sqlCon))
{
sqlCom.CommandText = "UPDATE Personel SET UserName = @username , Password = @pass WHERE ID = @id";
sqlCom.Parameters.Add (new SqliteParameter ("@username", TitleText.Text));
sqlCom.Parameters.Add (new SqliteParameter ("@pass", NotesText.Text));
sqlCom.Parameters.Add (new SqliteParameter ("@id",currentTask.Id));
sqlCom.ExecuteNonQuery ();
}
//end using sqlCom
sqlCon.Close ();
}
}
//end using sqlCon
} catch (Exception ex)
{
}
//end try catch
}
示例14: DeleteData
private void DeleteData(string databaseFile)
{
try
{
if (!File.Exists (databaseFile))
{
return;
}
//end if
// Connect to database
using (SqliteConnection sqlCon = new SqliteConnection (String.Format ("Data Source = {0}", databaseFile)))
{
sqlCon.SetPassword("haluk");
sqlCon.Open ();
using (SqliteCommand sqlCom = new SqliteCommand (sqlCon))
{
sqlCom.CommandText = "DELETE FROM Personel WHERE ID = @id";
sqlCom.Parameters.Add (new SqliteParameter ("@id",currentTask.Id));
sqlCom.ExecuteNonQuery ();
}
//end using sqlCom
sqlCon.Close ();
}
//end using sqlCon
new UIAlertView("silindi","tamam",null,"OK",null);
} catch (Exception ex)
{
new UIAlertView("hata",ex.Message,null,"OK",null);
}//end try catch
}
示例15: CreateData
private void CreateData(string databaseFile)
{
try
{
if (!File.Exists (databaseFile))
{
return;
}
using (SqliteConnection sqlCon = new SqliteConnection (String.Format ("Data Source = {0}", databaseFile)))
{
sqlCon.SetPassword("haluk");
sqlCon.Open ();
using (SqliteCommand sqlCom = new SqliteCommand (sqlCon))
{
sqlCom.CommandText = "INSERT INTO Personel (UserName, Password) VALUES (@username, @password)";
sqlCom.Parameters.Add (new SqliteParameter ("@username",TitleText.Text ));
sqlCom.Parameters.Add (new SqliteParameter ("@password", NotesText.Text));
sqlCom.ExecuteNonQuery ();
}
sqlCon.Close ();
}
} catch (Exception ex)
{ }
}