sqlite Attach Database

I'm new to xamarin. I'm trying to convert an existing iOS app. This app uses multiple sqlite files and uses the "attach database" feature in sqlite so we can access and join data in multiple files.
Is there a library that supports this. I've tried a couple of the sqlite libraries and the "attach database" statement will execute but when I try to select data in the db that I attached, it says that table doesn't exist.

Any suggestions?

Answers

  • ElvisXiaElvisXia Member, Forum Administrator, Xamarin Team Xamurai

    By "attach database", do you mean getting the connection to other database file? If so, you can use SQLite.Net to simply create a new connection with below codes:

    var db = new SQLiteConnection (dbPath);
    
  • cdpcdp Member

    No, I'm wanting 1 one connection to 2 files. With Sqlite, you can use the "attach database" sql statement to do this.

  • ElvisXiaElvisXia Member, Forum Administrator, Xamarin Team Xamurai

    @cdp by "one connection to 2 files" if you mean one SQLiteConnection instance to 2 files. Then it is not possible to do that. And also it is not necessary to do that. If you want to conduct the data of two files, what you need to do is simply create a new connection like this:

    var db1 = new SQLiteConnection (dbPath1);
    var db2 = new SQLiteConnection (dbPath2);
    

    Then you can CRUD the data of two SQLite files.

Sign In or Register to comment.