Write RTF to CubeSQLServer

Hello, I have some RTF files that I want to upload to my database. I checked out the SQLiteBlob example that ships with Xojo.

The trouble I’m having is when I’m hooked up to the server “CreateBlob” is not available to me. It is only available through “SQLiteDatabase”

When I open the database it looks like this so I can access the database through the server:

mDb = New CubeSQLServer //*not mDb = New SQLiteDatabase

I thought CubeSQLServer is an SQLiteDatabase so I’m confused and hoping to be set in the right direction on this.

If there’s a better way to store RTF files, I’m open to that as well… Thanks in advance!

Here’s the code from the Xojo example file:

[code]Dim file As FolderItem
file = GetOpenFolderItem("")

If file Is Nil Then Return

// Create row in File table
Dim rec As New DatabaseRecord
rec.Column(“FileName”) = file.Name
rec.IntegerColumn(“Size”) = file.Length

mDb.InsertRecord(“File”, rec)

// Get row ID
DIm dbRowID As Integer = mDB.LastRowID

// Add the file as blob to the newly added row
Dim blob As SQLiteBlob
blob = mDB.CreateBlob(“File”, “FileData”, dbRowID, file.Length)

If blob <> Nil Then
Dim bd As BinaryStream
bd = BinaryStream.Open(file, False)

Dim data As String
While Not bd.EOF
  data = bd.Read(1000)
  
  blob.Write(data)
  If blob.WriteError Then
    MsgBox("Error writing to BLOB.")
    bd.Close
    blob.Close
    
    Exit While
  End If
Wend
bd.Close
blob.Close

LoadFiles

End If[/code]

CubeSQL is not a SQLiteDatabase, at least from a Xojo language and class perspective, so it cannot use the SQLite BLOB stuff.

You’ll probably want to use a RecordSet and DatabaseField.NativeValue to set BLOB values.