Code: Alles auswählen
Protected.s SQL1, SQL2, sql9, id_name
Protected size, *mem, size2, *mem2
If CreateFile(1, fili$)
CloseFile(1)
If OpenDatabase(#CopyDB, fili$, "", "")
SQL1 = "CREATE TABLE datenbank (id INTEGER PRIMARY KEY, name TEXT, gruppe TEXT, version TEXT, beschreibung MEMO, tabelle longblob, picname TEXT, fotodata longblob, extdata longblob, extname TEXT)"
c = 0
v.f = 0
If DatabaseUpdate(#CopyDB, SQL1) = #False
Debug DatabaseError()
EndIf
If DatabaseQuery(#DB, "SELECT * FROM datenbank ORDER BY gruppe")
While NextDatabaseRow(#DB)
id_name = GetDatabaseString(#DB, 1)
size = DatabaseColumnSize(#DB, 7)
size2 = DatabaseColumnSize(#DB, 8)
Debug size
If size And Not size2
*mem = AllocateMemory(size)
If *mem
SQL2 = "INSERT INTO datenbank (name, gruppe, version, beschreibung, tabelle, picname, fotodata) "
SQL2 + "VALUES ('"
SQL2 + id_name + "','"
SQL2 + GetDatabaseString(#DB, 2) + "','"
SQL2 + GetDatabaseString(#DB, 3) + "','"
SQL2 + GetDatabaseString(#DB, 4) + "','"
SQL2 + GetDatabaseString(#DB, 5) + "','"
SQL2 + GetDatabaseString(#DB, 6) + "', "
SQL2 + "? )"
If GetDatabaseBlob(#DB, #row_FotoData, *mem, size)
SetDatabaseBlob(#CopyDB, 0, *mem, size)
DatabaseUpdate(#CopyDB, SQL2)
FreeMemory(*mem)
EndIf
EndIf
ElseIf size2 And Not size
*mem2 = AllocateMemory(size2)
If *mem2
SQL2 = "INSERT INTO datenbank (name, gruppe, version, beschreibung, tabelle, picname, extdata, extname) "
SQL2 + "VALUES ('"
SQL2 + id_name + "','"
SQL2 + GetDatabaseString(#DB, 2) + "','"
SQL2 + GetDatabaseString(#DB, 3) + "','"
SQL2 + GetDatabaseString(#DB, 4) + "','"
SQL2 + GetDatabaseString(#DB, 5) + "','"
SQL2 + GetDatabaseString(#DB, 6) + "', "
SQL2 + "? ,'"
SQL2 + GetDatabaseString(#DB, 9) + "')"
If GetDatabaseBlob(#DB, 8, *mem2, size2)
SetDatabaseBlob(#CopyDB, 0, *mem2, size2)
DatabaseUpdate(#CopyDB, SQL2)
FreeMemory(*mem2)
EndIf
EndIf
ElseIf size And size2
*mem = AllocateMemory(size)
*mem2 = AllocateMemory(size2)
If *mem And *mem2
SQL2 = "INSERT INTO datenbank (name, gruppe, version, beschreibung, tabelle, picname, fotodata, extdata, extname) "
SQL2 + "VALUES ('"
SQL2 + id_name + "','"
SQL2 + GetDatabaseString(#DB, 2) + "','"
SQL2 + GetDatabaseString(#DB, 3) + "','"
SQL2 + GetDatabaseString(#DB, 4) + "','"
SQL2 + GetDatabaseString(#DB, 5) + "','"
SQL2 + GetDatabaseString(#DB, 6) + "', "
SQL2 + "? , ? ,'"
SQL2 + GetDatabaseString(#DB, 9) + "')"
If GetDatabaseBlob(#DB, 7, *mem, size) And GetDatabaseBlob(#DB, 8, *mem2, size2)
SetDatabaseBlob(#CopyDB, 0, *mem, size)
SetDatabaseBlob(#CopyDB, 1, *mem2, size2)
DatabaseUpdate(#CopyDB, SQL2)
FreeMemory(*mem)
FreeMemory(*mem2)
EndIf
; Mit GetDatabaseBlob laden wir nun die Bilddaten in unseren Speicher.
EndIf
Else
SQL2 = "INSERT INTO datenbank (name, gruppe, version, beschreibung, tabelle, picname) "
SQL2 + "VALUES ('"
SQL2 + id_name + "','"
SQL2 + GetDatabaseString(#DB, 2) + "','"
SQL2 + GetDatabaseString(#DB, 3) + "','"
SQL2 + GetDatabaseString(#DB, 4) + "','"
SQL2 + GetDatabaseString(#DB, 5) + "','"
SQL2 + GetDatabaseString(#DB, 6) + "')"
DatabaseUpdate(#CopyDB, SQL2)
EndIf
c + 1
v = 100 / CountGadgetItems(#gad_ListView) * c
StatusBarProgress(#Statusbar, 1, Int(v), #PB_StatusBar_Raised) ;Wie kann ich das asynchron machen ?
Wend
FinishDatabaseQuery(#DB)
Else
Debug DatabaseError()
EndIf
CloseDatabase(#CopyDB)
StatusBarText(#Statusbar, 2, "Der Export war erfolgreich.")
MessageRequester("Programm", "Die Datenbank wurde erfolgreich exportiert!")
ListFuellen()
Else
Debug DatabaseError()
MessageRequester("Fehler", "Die Datenbank konnte nicht exportiert werden.")
End
EndIf
Else
Debug fili$ + " konnte nicht erstellt werden."
MessageRequester("Schreib-Fehler", "Die Datenbank konnte nicht erstellt werden.")
EndIf