New topic: 

attach database

<http://forums.realsoftware.com/viewtopic.php?t=41318>

         Page 1 of 1
   [ 3 posts ]                 Previous topic | Next topic          Author  
Message        suibaf          Post subject: attach databasePosted: Fri Nov 04, 
2011 3:22 pm                         
Joined: Tue Dec 16, 2008 9:08 am
Posts: 208
Location: Lecce (Italy)                I'm trying to attach a database to 
another, but i've some problem. I want copy NOR table from source db to minuto 
table in destination db.
It create new database file, but there is no data, no table. It is a empty 
file. My code is:

Code:
  dim f, g as FolderItem
  
  dim db_destination as new REALSQLDatabase
  dim  db_source as new REALSQLDatabase
  
  g = web_dbs.Child("db_" + numero_giornomese(mese) + "_"+ cstr(anno)+".rsd")  
//destination
  f = direttorio_sme.Child("dbsme").Child("db_" + numero_giornomese(mese) + 
"_"+ cstr(anno)+".rsd")  //source
  
  db_source.DatabaseFile = f
  db_destination.DatabaseFile = g
  
  db_source.DatabaseName = "db_source"
  
  if db_source.Connect then
  
  if db_source.AttachDatabase(g, "db_destination") then
  
  db_source.SQLExecute "Create table db_destination.minuto"
  db_source.SQLExecute "insert into db_destination.minuto select * from 
db_source.NOR"
  db_source.Commit
  db_source.DetachDatabase("db_destination")
  
  else
  
  Msgbox " Attach Fallito!"
  Exit
  
  end if
  
  else
  
  Msgbox "Non è possibile creare il report per la data selezionata"
  Exit
  
  end if


Can you help me?

Best regards      
_________________
RB2011R3
My native language is Italian, I'll try to make my posts understandable for 
everybody.  
                             Top                 timhare          Post subject: 
Re: attach databasePosted: Fri Nov 04, 2011 4:01 pm                         
Joined: Fri Jan 06, 2006 3:21 pm
Posts: 10382
Location: Portland, OR  USA                You're creating a table, but 
defining no columns.  I believe the syntax  you need is

create table db_destination.minuto as select * from db_source.NOR

It's all done in one statement.  It won't work if you try to use multiple 
statements as you did.   
                             Top                suibaf          Post subject: 
Re: attach databasePosted: Fri Nov 04, 2011 4:33 pm                         
Joined: Tue Dec 16, 2008 9:08 am
Posts: 208
Location: Lecce (Italy)                Hi Tim, thank you for your answer.

I've tryed the following code as your advice:

Code:  if sorgente_dati.Connect then
  
  if sorgente_dati.AttachDatabase(g, "db_destinazione") then
  
  sorgente_dati.SQLExecute "Create table db_destinazione.NOR as select * from 
db_sorgente.NOR"
  sorgente_dati.Commit
  sorgente_dati.DetachDatabase("db_destinazione")
  
  else
  
  Msgbox " Attach Fallito!"
  Exit
  
  end if
  
  else
  
  Msgbox "Non è possibile creare il report per la data selezionata"
  Exit
  
  end if


But the result no change. I have a database empty, with no table and no data.   
   
_________________
RB2011R3
My native language is Italian, I'll try to make my posts understandable for 
everybody.  
                             Top            Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 3 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to