本文整理汇总了C#中System.Data.SQLite.SQLiteConnection.Shutdown方法的典型用法代码示例。如果您正苦于以下问题:C# SQLiteConnection.Shutdown方法的具体用法?C# SQLiteConnection.Shutdown怎么用?C# SQLiteConnection.Shutdown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SQLite.SQLiteConnection
的用法示例。
在下文中一共展示了SQLiteConnection.Shutdown方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertToSqlite
public async void ConvertToSqlite(string pathToExcelFile)
{
SetPathToParentDirectoryOfDatabaseFile();
if (File.Exists(PathToDatabaseArchiveFile) && !File.Exists(_pathToDatabaseFile))
ZipFile.ExtractToDirectory(PathToDatabaseArchiveFile, _pathToDatabase);
using (
var dbSqLiteConnection =
new SQLiteConnection((WebConfigurationManager.ConnectionStrings["SQLite"].ConnectionString)))
{
//load data from xlsx(excel) file
var ds = await SetDataSet(pathToExcelFile);
await dbSqLiteConnection.OpenAsync();
//Set data from rows
for (var i = 0; i < ds.Tables[0].Rows.Count; i++)
{
var rowsStringBuilder = new StringBuilder();
//load data from row to string
for (var j = 0; j < ds.Tables[0].Rows[i].ItemArray.Length; j++)
{
var row = string.IsNullOrEmpty(ds.Tables[0].Rows[i][j].ToString())
? "NULL"
: ds.Tables[0].Rows[i][j].ToString();
if (j < ds.Tables[0].Rows[i].ItemArray.Length - 1)
rowsStringBuilder.Append(row + ",");
else
rowsStringBuilder.Append(row);
}
//Insert data into table
var sqlQuery = "Insert into " + TableName + "(" + ColumnNames + ") Values(" + rowsStringBuilder + ");";
using (var cmd = new SQLiteCommand(sqlQuery, dbSqLiteConnection))
await cmd.ExecuteNonQueryAsync();
}
dbSqLiteConnection.Shutdown();
dbSqLiteConnection.Close();
}
if (File.Exists(PathToDatabaseArchiveFile))
File.Delete(PathToDatabaseArchiveFile);
ZipFile.CreateFromDirectory(_pathToDatabase, PathToDatabaseArchiveFile);
}