SQLite file type set?

Can anyone provide me with the file type details for an SQLite database file?
I have looked in the File Type Set, but cannot see anything for a database.

I need to save a database file to the desktop, but can’t as I don’t know the file type details.

Thanks.

asked and answered here : https://forum.xojo.com/6710-filetype-question-sqlite-types

Dave - thanks I will try that.

I did as was recommended in the link - but no file gets saved?

Here is the button code:

[code]Dim source As FolderItem = SpecialFolder.ApplicationData.Child(“myFolder”).Child(“myDb.db”)

If source <> Nil Then
Dim Destination As FolderItem = GetSaveFolderItem(FileTypes1.SQLite,“myDb.db”)

If Destination.Exists Then
  source.CopyFileTo Destination
end If

End If[/code]

And here are my File Type Details:

FileTypes1
Display Name: SQLite
Object Name: SQLite
MacType: YYYY
MacCreator: XXXX
Extensions: .db
UTI: software.richardsummers.myApp (identical to my app’s bundle identifier)

Any other ideas on how to save an SQLite database file on OS X Cocoa?
It works fine if I hard code the Destination, but not if it is user selected.

If you debug the app, do you execute

source.CopyFileTo Destination

or is Source = Nil or Destination.Exists = false ?

CopyFile will NOT over-write an existing file (per the LR)

 If Destination.Exists Then
      Destination.delete
      source.CopyFileTo Destination
    end If

Torsten - No errors in the debugger and it works fine if I pre-define the destination directory.

Dave, there is no file to overwrite - if I select the desktop for example - no db file gets written there?

Richard… look at your own example

 If Destination.Exists Then
      source.CopyFileTo Destination
    end If

IF DESTINATION.EXISTS THEN

This means if the file I wish to copy to is already there… yet you now say it is NOT already there… in which case how would you expect the COPYFILETO to ever execute???

Does that mean, that you debugged the software and the line

source.CopyFileTo Destination

is executed without any Error?

In that case the CopyFileTo doesn’t work like expected. The Reference says:
"“If Destination is a file and the file already exists, the copy is aborted. You need to delete the existing file first. If there is an error, the LastErrorCode property contains an error code.”

I think Dave made the point :slight_smile:

Torsten - Yes - I get no little red bug signs, and the code steps through completely to the end.

Dave,
I tried this code, - to no avail?

[code]Dim source As FolderItem = SpecialFolder.ApplicationData.Child(“myFolder”).Child(“myDb.db”)

If source <> Nil Then
Dim Destination As FolderItem = GetSaveFolderItem(FileTypes1.SQLite,“myDb.db”)

If Destination.Exists Then
  Destination.delete
  source.CopyFileTo Destination

else
source.CopyFileTo Destination
end If

End If[/code]

Richard
please check the following

If Destination.Exists Then
      source.CopyFileTo Destination
     if source.LastErrorCode > 0 then
        MsgBox(Str(source.LastErrorCode))
     end if
end If

Ok, even though I do not see any little red bugs in the debugger, I have noticed that when I press the backup button - I am returned to the debugger, whereby I looked in the variables area at the bottom of the window - it says source nil

However - the folder called myFolder is definitely there, and it definitely contains the db file called myDb.db

Dim source As FolderItem = SpecialFolder.ApplicationData.Child("Snippet Data").Child("Snippets.db")
  
  If source <> Nil Then
    Dim Destination As FolderItem = GetSaveFolderItem(FileTypes1.SQLite,"Snippets.db")

if destination=nil then msgbox "BAD DESTINATION"
If source=NIL or not source.exists then msgbox "BAD SOURCE"
    
    If Destination.Exists Then destination.delete

      source.CopyFileTo Destination
      
      if source.LastErrorCode > 0 then
        MsgBox(Str(source.LastErrorCode))
      end if
    
 
  End If

make sure also the source (it is a database right?) is closed.

Dave - just tried your code and when I run the app and press the backup button - the software just hangs.

Ahh - the close thing must be the problem - BUT why would it then copy perfectly if I pre-define the destination, but not if user defined? Just trying to learn :slight_smile:

Assuming the Source is not nil and Source Exists and Destintation is not NIL (and of course that Source<>Destination) I see nothing wrong at all

Put a break point in… step thru it one line at a time… see what the values are at each step.

Dave,
just re-installed Xojo and it now works perfectly (even though the database is open).

Thank you so much for the advice and help - I really appreciate it!