Exemple #1
0
    protected int OnInsert(string sqliteDataSource, IList <ILogins> logins, Action <int, int> onProgress)
    {
        SQLiteFactory factory = (SQLiteFactory)DbProviderFactories.GetFactory("System.Data.SQLite");

        using (SQLiteConnection conn = (SQLiteConnection)factory.CreateConnection())
        {
            conn.ConnectionString = "Data Source = " + sqliteDataSource;
            conn.Open();

            DataTable allTables = SQLiteHelper.GetAllTables(conn);
            if (!SQLiteHelper.CheckValueExists(allTables, "name", loginsTable))
            {
                Console.WriteLine(string.Format("Can't find table '{0}' in db at path {1}", loginsTable, sqliteDataSource));
                return(0);
            }

            return(SQLiteHelper.InsertAll(conn, loginsTable, BrowserHelper.Convert(logins), onProgress));
        }
    }