{"action":"created","issue":{"url":"https://api.github.com/repos/oysteinkrog/SQLite.Net-PCL/issues/266","labels_url":"https://api.github.com/repos/oysteinkrog/SQLite.Net-PCL/issues/266/labels{/name}","comments_url":"https://api.github.com/repos/oysteinkrog/SQLite.Net-PCL/issues/266/comments","events_url":"https://api.github.com/repos/oysteinkrog/SQLite.Net-PCL/issues/266/events","html_url":"https://github.com/oysteinkrog/SQLite.Net-PCL/issues/266","id":122088527,"number":266,"title":"ATTACH Database","user":{"login":"AlessioVecchi","id":1484675,"avatar_url":"https://avatars.githubusercontent.com/u/1484675?v=3","gravatar_id":"","url":"https://api.github.com/users/AlessioVecchi","html_url":"https://github.com/AlessioVecchi","followers_url":"https://api.github.com/users/AlessioVecchi/followers","following_url":"https://api.github.com/users/AlessioVecchi/following{/other_user}","gists_url":"https://api.github.com/users/AlessioVecchi/gists{/gist_id}","starred_url":"https://api.github.com/users/AlessioVecchi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlessioVecchi/subscriptions","organizations_url":"https://api.github.com/users/AlessioVecchi/orgs","repos_url":"https://api.github.com/users/AlessioVecchi/repos","events_url":"https://api.github.com/users/AlessioVecchi/events{/privacy}","received_events_url":"https://api.github.com/users/AlessioVecchi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-12-14T17:18:04Z","updated_at":"2016-01-02T20:26:38Z","closed_at":null,"body":"Hi \r\n\r\nI have read Shine answer to post:\r\n\r\nhttps://github.com/oysteinkrog/SQLite.Net-PCL/issues/181\r\n\r\nI have followed the solution he wrote \r\n\r\npublic void CatalogAttachDelta(string catalogID, ref SQLiteConnection catalogConnection)\r\n{\r\nvar attachCommand = catalogConnection.CreateCommand(string.Format(\"ATTACH DATABASE '{0}' AS '{1}'\", this.config.CatalogDeltaDatabasePath(catalogID), \"DeltaDb\"));\r\n       attachCommand.ExecuteNonQuery();\r\n}\r\n\r\n...\r\n\r\nthis.dataStore.CatalogAttachDelta(catalogID, ref catalogConnection);\r\n...\r\nThen with catalogConnection I execute a list of commands:\r\n..\r\nvar actionCommand = catalogConnection.CreateCommand(“<ACTION>”);\r\nint rowAffected = actionCommand.ExecuteNonQuery();\r\n..\r\nbut I don’t have what I expected. \r\nIn particular the actions doesn’t raise error but it doesn’t have none effect. \r\n\r\nWhere actions is a complex statement:\r\n<ACTION> =         \r\nCREATE TABLE IF NOT exists[brands](   [id] INTEGER PRIMARY KEY NOT NULL,   [title] [nvarchar](1000) NOT NULL  );;\r\n        CREATE TABLE IF NOT exists[deleted_brands]( Id INTEGER PRIMARY KEY NOT NULL);\r\n        DELETE FROM Main.brands WHERE Id IN(SELECT Id FROM DeltaDb.brands);\r\n        INSERT INTO Main.brands SELECT * FROM DeltaDb.brands;\r\n        DELETE FROM Main.brands WHERE Id IN(SELECT Id FROM DeltaDb.deleted_brands);\r\n\r\nDo you have any ideas?\r\n\r\nThanks in advance.\r\n\r\nAlessio\r\n"},"comment":{"url":"https://api.github.com/repos/oysteinkrog/SQLite.Net-PCL/issues/comments/168426309","html_url":"https://github.com/oysteinkrog/SQLite.Net-PCL/issues/266#issuecomment-168426309","issue_url":"https://api.github.com/repos/oysteinkrog/SQLite.Net-PCL/issues/266","id":168426309,"user":{"login":"StyrianOak","id":11632314,"avatar_url":"https://avatars.githubusercontent.com/u/11632314?v=3","gravatar_id":"","url":"https://api.github.com/users/StyrianOak","html_url":"https://github.com/StyrianOak","followers_url":"https://api.github.com/users/StyrianOak/followers","following_url":"https://api.github.com/users/StyrianOak/following{/other_user}","gists_url":"https://api.github.com/users/StyrianOak/gists{/gist_id}","starred_url":"https://api.github.com/users/StyrianOak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StyrianOak/subscriptions","organizations_url":"https://api.github.com/users/StyrianOak/orgs","repos_url":"https://api.github.com/users/StyrianOak/repos","events_url":"https://api.github.com/users/StyrianOak/events{/privacy}","received_events_url":"https://api.github.com/users/StyrianOak/received_events","type":"User","site_admin":false},"created_at":"2016-01-02T20:26:38Z","updated_at":"2016-01-02T20:26:38Z","body":"Hi,\r\nI'm doing also ATTACH a second db. After problems I use different tablenames in the main- and attached db, it worked for me.\r\nRegards - Klaus"}}