How To make a relations, SQLITE two database, two files ?

If I have two database Sqlite, How do I make the relationship if I have a file in one and another in another? With two files in the same database, I solved by reference. But when the bases are different?

In this examplem,wth Two files (Diario_P_xxx, PlanCta) , on the same database works fine !!!

Note: this is a Function named “LeerDatosAstos” with two parameters ( queList as Listbox, queFiltro as string)

[code] ’ ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### #####
’ Consultora Informtica Dieminger - GreenLine Software
’ Marambio 551 1P - Ober (3360) - ConsultoraDieminger@hotmail.com
’ Ruben Anibal Dieminger ( Informtico ) Matr.Prof 036
’ ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** *****
’ Acction: Read data and put in a recordset
’ ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** *****
App.errWinVentana = Me.title
App.errWinMethod = CurrentMethodName
’ ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### #####

dim SQLString as string
dim SQLTable as string
dim SQLTable1 as String =“Diario_P_”+App.mEjer
dim SQLTable2 as String = “PlanCta”

’ Two Files, in same Sqlite databse

SQLTable = SQLTable1 +","+SQLTable2

’ ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
’ Check if Dabase Open ?
’ ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
if App.mDbContab.Connect = false then
call App.BD_contabVerifSiExiste()
if App.mDbContab_Connected = false then return
end if

’ ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
’ Remove all rows from the listbox
’ ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
queList.DeleteAllRows
dim haySel as boolean = false

’ ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
’ Make a SQLITE STRING
’ ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----

SQLString = “Select “+SQLTable1+”.Fecha,”
SQLString = SQLString +SQLTable1 +".Asiento,"
SQLString = SQLString +SQLTable1 +".NroCta,"
SQLString = SQLString +SQLTable2 +".Denominacion as DetallePlanCta,"
SQLString = SQLString +SQLTable1 +".Detalle,"
SQLString = SQLString +SQLTable1 +".Cpbte,"
SQLString = SQLString +SQLTable1 +".Cod,"
SQLString = SQLString +SQLTable1 +".Debe,"
SQLString = SQLString +SQLTable1 +".Haber"+chr(32)
SQLString = SQLString + “FROM “+SQLTable + chr(32)
if queFiltro <>”” then
’ External “Where” condition !!!
SQLString =SQLString + queFiltro
end if

’ ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
’ Check if work local Sqlite database or Web MySql
’ ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----

if app.BaseDatosMySql_Local = false then

' Check internet Work Fine ?

if App.TestInternetOn() = false then
  App.SleepCurrentThread (2000)
  if App.TestInternetOn() = false then
    App.SleepCurrentThread (2000)
    if App.TestInternetOn() = false then
      Msgbox("Internet OFF, try again in a few minutes")
      Return
    end if
  end if
end

End if

’ ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
’ Conection OK, read data in a RecordSet
’ ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----

try

dim rs as RecordSet
rs = App.mDbContab.SQLSelect(SQLString)
if rs = Nil  then
  
  ' ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- 
  ' Sheeettt, string errror
  ' ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- 
  App.errWin_Base = "Contab"
  App.errWin_Table = SQLTable
  App.errWin_Sqlstring = SQLString
  app.MessProg = "No se pudo leer las bases de datos  [Diario_P_eXX,PlanCta]"+EndOfLine //Imposible read database  
  app.MessProg = app.MessProg+ str(App.mDbContab.ErrorCode) +" "
  app.MessProg = app.MessProg+ App.mDbContab.ErrorMessage +EndOfLine
  app.MessProg = app.MessProg +"Sugerencia: revisar sintaxis " //Suggest: Check  String Sintax
  wfn_ErrNil.showModal
  return
  
end if

dim n as integer = 0

while not rs.EOF
  
  
  queList.AddRow ""
  
  ' Usual files to read: Fecha,Asiento,NroCta,PlanCta.Denominacion,Detalle,Cpbte,Cod,Debe,Haber
  
  ' 00 Fecha
  n =  0
  queList.Cell(queList.LastIndex, n) = rs.Field("Fecha").Value
  
  '01  Asiento
  n = n +1
  queList.Cell(queList.LastIndex, n) = rs.Field("Asiento").Value
  
  '02 NroCta
  n = n +1
  queList.Cell(queList.LastIndex,n) = rs.Field("NroCta").Value
  
  '03 Denominacion
  n = n +1
  queList.Cell(queList.LastIndex,n) = rs.Field("DetallePlanCta").Value
  
  '04 Detalle
  n = n +1
  queList.Cell(queList.LastIndex,n) = rs.Field("Detalle").Value
  
  '05 Cpbte
  n = n +1
  queList.Cell(queList.LastIndex,n) = rs.Field("Cpbte").Value
  
  '06 Cod
  n = n +1
  queList.Cell(queList.LastIndex,n) = rs.Field("Cod").Value
  
  '07 Debe
  n = n +1
  queList.Cell(queList.LastIndex,n) = rs.Field("Debe").Value
  
  '08 Haber
  n = n +1
  queList.Cell(queList.LastIndex,n) = rs.Field("Haber").Value
  
  ' ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
  ' Next RecordSet
  ' ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
  rs.MoveNext
  
wend

Exception err

' Excepton err, show (SPANISH)

 app.MessProg = "Err x  Excepcin En -> ("+App.errWinMethod+")" +EndOfLine
    
If err IsA TypeMismatchException then
  App.messprog = App.messprog + "La variable asignada debe ser de otro tipo ( Numero, texto) " +EndOfLine + EndOfLine
elseif err IsA NilObjectException then
  '
  App.messprog = App.messprog + "Se est intentando acceder a un objeto que no existe " +EndOfLine + EndOfLine
end
MsgBox App.messprog
return

end try[/code]

Look into Attaching another database

Yeaaah works fine… Thanks Norman.