The following forum(s) have migrated to Microsoft Q&A (Preview): Developing Universal Windows apps!
Visit Microsoft Q&A (Preview) to post new questions.

Learn More

[W8.1]Merge two sqlite database in Windows Metro Apps C# RRS feed

  • Question

  • I have two sqlite databases and want to merge all the contents of multiple tables. I followed this article:Merging two SQLite database files (C# .NET) But this doesn't work in C# Metro apps/ Windows 8.1/ Windows Phone 8.1 apps. I tried the following code:

    SQLiteAsyncConnection connection1 = new SQLiteAsyncConnection("Employee.sqlite");
    SQLiteAsyncConnection connection2 = new SQLiteAsyncConnection("Customer.sqlite"); 
    var result = await connection1.QueryAsync<TableEmployee>("Select Name, Address FROM TableEmployee");
            foreach (var item in result)
                var EmployeeList = new List<TableEmployee>()
                new TableEmployee()
                    Name = item.Name,
                    Address = item.Address
                await connection2.InsertAllAsync(EmployeeList);

    I attempted to solve this by implementing a simple logic as follows:

    1. Read all the contents from one table of first database.

    2. Next, Insert them all into the next table of another database.

    This code snippet reads all the Columns: "Name" and "Address" from table "TableEmployee" of first database "Employee.sqlite" and inserts into Table "TableCustomer" of second database "Customer.sqlite" which have also same two columns "Name" and "Address".

    If there are multiple tables, how to do that? Is there any other way to solve this? Help please!

    Friday, May 15, 2015 7:03 AM