Saving a file into database's binary field(FileStream -> BinaryReader -> LinQ)


Public Sub RaporKaydet(aRID As Integer)

Dim filename As String = "c:\r1.repx"
Dim fs As FileStream = New FileStream(filename, FileMode.Open, FileAccess.Read)
Dim br As BinaryReader = New BinaryReader(fs)
Dim byt As Byte() = br.ReadBytes(fs.Length)

br.Close()
fs.Close()

Using mn As New DataClassesRapor_DizaynDataContext
Dim ty = (From k In mn.TBLRAPOR_DIZAYNs Where k.RID = aRID
Select k).First

ty.Report = byt

mn.SubmitChanges()
End Using
End Sub


Yorumlar