Store Files In Database and Retrieve in VB .net

cementboot

Member
Joined
Aug 27, 2005
Messages
8
Hi,

I am trying to figue out the easiest way to store files of any type in a database and then display them in a VB .net application. The concept sounds simple, but I have not been able to find a solution yet. I would be incredibly grateful for any feedback.
 
cementboot said:
Hi,

I am trying to figue out the easiest way to store files of any type in a database and then display them in a VB .net application. The concept sounds simple, but I have not been able to find a solution yet. I would be incredibly grateful for any feedback.
search for saving images to a database, its no different.
 
Joe Mamma said:
search for saving images to a database, its no different.


Thanks for your help Joe Mamma. I have attached a project (from planet source code) that I am trying to modify for my needs. It currently loads pictures into a picturebox on the from an Access DB. What I am trying to do is it to load an .rtf file from the Access DB into a richtextbox instead. The code I cant figue out is as follows:

Code:
Private Sub LoadImage(ByVal recNo As Integer, ByVal dirn As Direction)
        Dim arr() As Byte

        Select Case dirn
            Case Direction.NextImage
                If recNo <= ds.Tables(0).Rows.Count - 1 Then
                    lblCount.Text = Val(lblCount.Text) + 1
                Else
                    Exit Sub
                End If
            Case Direction.PreviousImage
                If recNo > 0 Then
                    lblCount.Text = Val(lblCount.Text) - 1
                    recNo = recNo - 1
                Else
                    Exit Sub
                End If
        End Select

        arr = ds.Tables(0).Rows(recNo).Item(0)
[B]
        +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        How can I load the OLE object into the RichTextBox instead of a picture box?[/B]
      [COLOR=Red]  picLoad.Image = picLoad.Image.FromStream(New IO.MemoryStream(arr))
[/COLOR][B]
        ???????????
        ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

[/B]
        NOTE: If you want to save the image to a file, you can use the following code:
        FileOpen(1, "filename", OpenMode.Binary)
        FilePut(1, arr)
        FileClose(1)
    End Sub

I would think it would be something like:

Code:
[COLOR=Red]richtextbox1.text = richtextbox.text.FromStream(New IO.MemoryStream(arr))[/COLOR]

But that doesnt seem to work

Thanks Again,
CementBoot
 

Attachments

Last edited by a moderator:
Back
Top