Previous Top Next

Loads the data of the specified file and converts it to BLOB type before saving it in a database.
Syntax: FileToBLOB (File As String) As String

'con is a Connection object, cmd is a Command object and reader is a DataReader object.
Sub Globals

End Sub

Sub App_Start
      con.Open("Data Source = " & AppPath & "\1.db3") 'Opens the database.
      cmd.New1("CREATE TABLE IF NOT EXISTS pictures (name TEXT, image BLOB)",con.Value)
      'Save the image in the database (change the image name to an existing image file).
      cmd.CommandText = "INSERT INTO pictures values('smiley.gif'," & cmd.FileToBLOB(AppPath & "\smiley.gif") & ")"
      'Load the image from the database.
      cmd.CommandText = "SELECT image FROM pictures"
      reader.Value = cmd.ExecuteReader
      Form1.Image = reader.GetImage(0)
End Sub