OK here's my code which is just test code, not intended to do anything useful. It runs without error, but the DELETE just doesn't do anything Dim dbConnection As New SQLiteConnection Dim dbDataSet As New DataSet Dim SQLStmt As String Dim sDBPath As String = Application.StartupPath & "\wolfpro.db3" Dim sUpdateDBPath As String = Application.StartupPath & "\UpdateWolfpro.db3" Try If dbConnection.State = ConnectionState.Closed Then dbConnection.ConnectionString = "Data Source=" & sDBPath & ";New=True;Compress=True;Synchronous=Off" dbDataSet.Locale = CultureInfo.InvariantCulture dbConnection.Open() dbDataSet.Reset() End If SQLStmt = "ATTACH '" & sUpdateDBPath & "' AS UPD;" Dim dbcommand As SQLiteCommand = dbConnection.CreateCommand With dbcommand .CommandText = SQLStmt .ExecuteNonQuery() .Dispose() End With SQLStmt = "DELETE FROM UPD.Items;" Dim dbcommand2 As SQLiteCommand = dbConnection.CreateCommand With dbcommand2 .CommandText = SQLStmt .ExecuteNonQuery() .Dispose() End With Return True Catch ex As Exception MessageBox.Show(ex.Message) Return False End Try
On 13 August 2015 at 10:12, R.Smith <rsmith at rsweb.co.za> wrote: > To Attach a second Database is fairly straightforward and shouldn't fail > unless there is a physical problem with either of the files. > > The Attach command example is like this (on a WinX machine): > > ATTACH DATABASE 'C:\Documents\OtherDatabase.db' AS "DB2"; > > Execute that as a standard SQL statement. If that file does not exist, it > will be created - but the path needs to be valid. > If that statement does not work for you, please let us know what the error > message is. > > Once the statement did work, the second database can be accessed by > prepending any reference with "DB2", so assuming you have a table in the > current database called "MyTable" that needs to add rows that doesn't exist > yet in the same named (with the same schema) table in the attached database > on a Primary key called "RecID", this SQL might work: > > INSERT INTO DB2.MyTable SELECT * FROM MyTable WHERE MyTable.RecID NOT > IN (SELECT RecID FROM DB2.MyTable); > > More information here: > http://www.sqlite.org/lang_attach.html > > On 2015-08-13 07:13 AM, Chris Parsonson wrote: > >> Now we get down to the first real problem that of the ATTACH. I have never >> been able to get that to work. If I could have got the ATTACH to work I >> probably would never have had to ask the synchronisation question. >> Although >> I have never had to do it before in SQLite, I have worked a lot with SQL >> Server doing synchronisation there >> > > > > > _______________________________________________ > sqlite-users mailing list > sqlite-users at mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > -- Chris Parsonson 083 777 9261