Consider a case when you have multiple databases available and you want to use any one of them at a time. SQLite ATTACH DATABASE statement is used to select a particular database, and after this command, all SQLite statements will be executed under the attached database.
Syntax
Following is the basic syntax of SQLite ATTACH DATABASE statement.
ATTACH DATABASE ‘DatabaseName’ As ‘Alias-Name’;
The above command will also create a database in case the database is already not created, otherwise it will just attach database file name with logical database ‘Alias-Name’.
What syntax would be for ATTACH for CubeSQL server using Xojo? Any idea?
Both databases are on the same remote server. There is no problem to connect to any of them, separately. Is there a problem, because both databases are on the same remote Volumes?
Hi Tim,
many thanks for your help.
I still have 2 databases on remote server: db1.sqlite and db2.sqlite. Server IP address: 192.168.60.10
I did the connection with one databases as you suggested:
db2 = New CubeSQLServer
db2.Host = "192.168.60.10
db2.Port = 4430
db2.UserName = “admin”
db2.Password = “admin”
db2.DatabaseName = “db2.sqlite”
if (db2.Connect = false) then
MsgBox “Connection failed: " + db2.ErrorMessage + " (” + Str(db2.ErrorCode) + “)”
return
end if
db2.ExecuteSQL(“ATTACH DATABASE db1.sqlite AS dbName;”)
Dim rsNames As RecordSet = db2.SQLSelect(“SELECT * FROM Number INNER JOIN Name ON NumberID = NameID”)
where “Number” is Column from db1.sqlite and “Name” is Column from dbName (db1.sqlite) database.
The problem remains the same. Is it possible to get the code from you?
Hi Tim,
Still doesn’t work. Obviously I did not give you all necessary data about the dabasases. Now I put the databases on “localhost” instead on remote server. I would like to send you the Xojo code with databases. Is it possible to get your e-mail?
Database: db_P.sqlite
Table: Numbers
Column: Number
I’m sorry, I don’t have any experience with CubeSQL in order to guide you on the path to use. Try trimming parts off from the front. It might be /databases/databases/db_N.sqlite