SQL dumping...

Chuck rwc1717 at shaw.ca
Sun Aug 3 16:27:39 CDT 2003


Hi Ruslan:
	The following code takes your sqldump file and restores all the records that it 
finds in file. it isn't very pretty but it works...I will try it out on the windows unit as 
soon as I can but I see no reason why the code should fail.

	Thanks for the tip.
Chuck

dim i,j as integer
dim s,t as String
dim InNewDb,InDumpFile as FolderItem
dim Fileread as TextInputStream 
inNewDb = new Folderitem(whatever.vdb")
inDumpFile = new FolderItem("whatever.sql")
if InNewDb exists then
 InNewDb.Delete
end if
mDb.Flush
mDB.Close
mDB = Nil
mDb = new bcsDB
mDb.Creator = "VALA"       // optional
res = mDb.Create( inNewDb, 1, 32 * 1024 )
if(res = false) then 
   MsgBox "Can't create database. Error: " + Str(mDb.ErrNumber)+" - 
"+mDb.ErrString+"   
    Quit
  end if
  fileread = InDumpFile.OpenasTextFile
  do
    t = FileRead.Readline
    if mid(t,1,6) = "INSERT" then
      i = len(t)
      s = mid(t,1,i-1)
      j = mDb.SQLExecute(s)
    end if
  loop Until fileread.EOF 
  FileRead.Close
  mDB.Flush



More information about the Valentina mailing list