Store image in SQL Database using

Store image in SQL data base it is not a new thing in SQL and which I going to explain
To store the image in database we convert the image in bytes in and then it send to database to will very simple step to store it.

Download ::

1).  Create a table called ImagesStore.

CREATE TABLE ImagesStore (ImageId int IDENTITY (1, 1) NOT NULL ,OriginalPath varchar (200)  NOT NULL ,ImageData image NOT NULL)

2). Then the main code is written in . Bellow code is use to convert the image into byte and the send it to the database to store.

Convert the image and send it to database:

Dim str As String
        Dim fstream As FileStream
        Dim imgdata As Byte()
        Dim data As Byte()
        Dim finfo As FileInfo
        finfo = New FileInfo(TextBox3.Text)
        Dim numbyte As Long
        Dim br As BinaryReader
        numbyte = finfo.Length
        fstream = New FileStream(TextBox3.Text, FileMode.Open, FileAccess.Read)
        br = New BinaryReader(fstream)
        data = br.ReadBytes(numbyte)
        imgdata = data
        con = New SqlConnection(TextBox1.Text)
        str = "insert into ImagesStore (OriginalPath,ImageData) values(@op, @i)"
        cmd = New SqlCommand(str, con)
        cmd.Parameters.Add(New SqlParameter("op", SqlDbType.Char, 200))
        cmd.Parameters("op").Value = TextBox1.Text
        cmd.Parameters.Add(New SqlParameter("i", SqlDbType.Image))
        cmd.Parameters("i").Value = imgdata
        MsgBox("Image Inserted In DataBase..", MsgBoxStyle.Information)
End Sub

 3). to retrieve the image from the database and display in the Picture Box .below code is responsible for display the picture in picture box. The main function of code is to retrieve the data in bytes and convert it to a normal image and display it.

Dim imagedata As Byte()
            PictureBox1.Location = New Point(3, 3)
            Timer1.Enabled = False
            imagedata = (DataGridView1.Rows(e.RowIndex).Cells("ImageData").Value)
            Dim ms As MemoryStream
            ms = New MemoryStream(imagedata, 0, imagedata.Length)
            ms.Write(imagedata, 0, imagedata.Length)
            Dim im As Image
            im = Image.FromStream(ms, True)
            PictureBox1.Image = im
        Catch ex As Exception
            Timer1.Enabled = True
        End Try