I want to store large files(over 100mb) in a sqlite database. I noticed, that its not good in performance.
Do I have to store the files in a local folder, or do i have to rewrite my code?
Shared Sub BlobToFile(ByVal Blob As Byte(), ByVal file As String)
Dim MyData() As Byte = Blob
Dim K As Long
K = UBound(MyData)
Dim fs As New FileStream _
(file, FileMode.Create, _
FileAccess.Write)
fs.Write(MyData, 0, K)
fs.Close()
MyData = Nothing
K = Nothing
End Sub
Shared Function FileToBlob(ByVal Filepath As String) As Byte()
Dim fs As New FileStream _
(Filepath, FileMode.Open, _
FileAccess.Read)
Dim MyData(fs.Length) As Byte
fs.Read(MyData, 0, fs.Length)
fs.Close()
Return MyData
End Function
'Then I Do this:
Dim x As New Sqliteparameter With {.Name ="@file", .value=Filetoblob("C:\Testfile.zip"), .DbType.Binary}
Dim y As New SqliteCommand With {.Commandtext = "INSERT INTO FILES(File) Values(@file);"}
y.Parameters.add(x)
y.Executenonquery()
Thx
It is generally best practice to not store large files inside a database unless there is support for it such as with mssql server. I would reccomend looking at just storing the location of the file in the database and storing the file in some sort of file system.