ISH777 0 Newbie Poster

ISH777
//Hello Everyone, I have a Problems Regarding with the IMAGE
I create a Program That save Information of END USERS including Image... but the Image will save into Bytes.....and I have no Problem in that as you seen below.....

Dim xx As String = "insert into tbl_BorrowersInfo (accountno, sname, fname, mname, photo) values ('" & txt_AccountNo.Text & "','" & txt_SNme.Text & "','" & txt_FName.Text & "','" & txt_MI.Text & "', @photo)"
Dim cmd As New SqlCommand(xx, con)
Dim ms As New MemoryStream()

PictureBox1.Image.Save(ms, PictureBox1.Image.RawFormat)
Dim data As Byte() = ms.GetBuffer()
Dim p As New SqlParameter("@photo", SqlDbType.Image)
p.Value = data
cmd.Parameters.Add(p)
cmd.ExecuteNonQuery()

//This is My Problem i have this Search Engine that can Search information that can show the information needed from the database....... it works Nicely but I don't know how to show/Retrieve the Image from Bytes to Image itself and show it into the PictureBox1.. the code shown Below.. Please Help me.. thanks..

con.Open()
Dim ab As New SqlCommand("select accountno,sname, fname, mname,photo from tbl_BorrowersInfo where accountno like '%" & searchstring & "%' or sname like '%" & searchstring & "%' or fname like '%" & searchstring & "%' or mname like '%" & searchstring & "%'", con)
Dim bc As SqlDataReader = ab.ExecuteReader()
bc.Read()
If bc.HasRows Then

If bc.HasRows Then
txt_No.Text = bc("no")
txt_AccountNo.Text = bc("accountno")
cmb_ReaderType.Text = bc("usertype")
txt_SNme.Text = bc("sname")
txt_FName.Text = bc("fname")
txt_MI.Text = bc("mname")
PictureBox1.Image = bc("photo")
End If()
con.Close()

PictureBox1.Image = bc("photo") is Showing Error because it is not Converted from BYTES to IMAGE ..PLs pls pls Help (-_-)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.