I replied to a near same question some weeks ago, here is it the code
I posted:
The best solution is to attach the file based db to the in memory db
and then do a cross insert/select, like:
INSERT INTO fileDB.test1 select * from test1
This is a fully working example (RB2006 syntax):
Dim memDB As new REALSQLDatabase
Dim db As new REALSQLDatabase
Dim f As FolderItem = GetFolderItem("").Child("test.rsd")
Dim createTableSQL As String = "CREATE TABLE test1 (field1 text,
field2 text, field3 text)"
// Create in memory db
if not memDB.Connect then
MsgBox "Error while creating in memory db"
return
end if
// Create in memorty table
memDB.SQLExecute(createTableSQL)
if (memDB.Error) then
MsgBox memDB.ErrorMessage
Return
end if
// Insert some dummy values
memDB.SQLExecute("INSERT INTO test1 (field1, field2, field3)
VALUES ('test1', 'test2', 'test3')")
memDB.SQLExecute("INSERT INTO test1 (field1, field2, field3)
VALUES ('test1', 'test2', 'test3')")
memDB.SQLExecute("INSERT INTO test1 (field1, field2, field3)
VALUES ('test1', 'test2', 'test3')")
memDB.SQLExecute("INSERT INTO test1 (field1, field2, field3)
VALUES ('test1', 'test2', 'test3')")
memDB.SQLExecute("INSERT INTO test1 (field1, field2, field3)
VALUES ('test1', 'test2', 'test3')")
// Create file based db
db.DatabaseFile = f
if (not db.CreateDatabaseFile) then
MsgBox "Error while creating file db"
return
end if
// Create file based table
db.SQLExecute(createTableSQL)
if (db.Error) then
MsgBox db.ErrorMessage
Return
end if
// Close all pending transactions or attach fails
db.Commit
memDB.Commit
if not memDB.AttachDatabase(f, "fileDB") then
MsgBox memDB.ErrorMessage
return
end if
// Dump all records from memory to disk
memDB.SQLExecute("BEGIN TRANSACTION")
memDB.SQLExecute("INSERT INTO fileDB.test1 select * from test1")
memDB.Commit
memDB.DetachDatabase("myFileDB")
// Close db(s)
memDB.Close
db.Close
---
Marco Bambini
http://www.sqlabs.net
http://www.sqlabs.net/blog/
On May 5, 2006, at 3:38 PM, José Andrés wrote:
Hello people
I have a REALSQLDB in a file, I need convert it in a memory
database and working with this in my app, later I need to put all
the changes in the file I told before.
How can I do this in a easy way?, I mean convert the file in memory
DB and return to a file.
Regards, Jose
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>