Hi,
still not getting the retrive the image FROM Access Database... i wrote the code...But iam getting these Error.... So pls Make it....
Unable to cast of type 'system.String'to type 'System.Byte[]'
Private Sub cmb_id_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmb_id.SelectedIndexChanged
Try
'Dim Emp_id As String = ""
MsgBox(cmb_id.SelectedItem)
con.Close()
con.Open()
cmd = New OleDbCommand("select * from emp_details_tab where emp_id=" & cmb_id.SelectedItem & "", con)
dr = cmd.ExecuteReader()
While dr.Read()
txt_name.Text = dr.GetValue(1) '("emp_name")
txt_address.Text = dr.GetValue(2) 's("emp_address")
MaskedTextBox1.Text = dr.GetValue(3) '("dob")
MaskedTextBox2.Text = dr.GetValue(4) '("doj")
txt_qualify.Text = dr.GetValue(5) '("Qualify")
txt_no_yrs_exp.Text = dr.GetValue(6) '("No_Of_Yrs")
txt_worked_exp.Text = dr.GetValue(7) '("Experinced_Details")
Dim retval As Long
Dim buffersize As Integer = 100
Dim outbyte(buffersize - 1) As Byte
Dim bw As BinaryWriter
Dim k As Long
Dim fs As New IO.FileStream("employ_Image", FileMode.OpenOrCreate, FileAccess.Write)
bw = New BinaryWriter(fs)
k = 0
retval = dr.GetBytes(1, k, outbyte, 0, buffersize)
Do While retval = buffersize
bw.Write(outbyte)
bw.Flush()
k += buffersize
retval = dr.GetBytes(1, k, outbyte, 0, buffersize)
Loop
bw.Write(outbyte, 0, retval - 1)
Emp_image.Image = Image.FromFile(filepath)
bw.Close()
fs.Close()
MsgBox("Image Retrived")
End While
Catch ex As Exception
MsgBox(ex.Message)
Finally
con.Close()
End Try
EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.com