image in asp.net

  • Thread starter Thread starter Sam
  • Start date Start date
hi guys,
could you give me a sample program (if possible in vb.net) to display
picture from sql server using image control (but i don't like to save the
image in file and then display it).
maybe you have better idea ?
thanks,
 
yes, i have read the article, and i use the the dynamicimage control, but
there is something i don't understand, please look sample code below:

private function getEmployeePhoto(empid as integer) as byte()
............' code program............
end function

private sub button1_click(..)....
dynamicImage1.imageBytes=getEmployeePhoto(3)
end sub

private sub button2_click(..)....
dynamicImage1.imageBytes=getEmployeePhoto(5)
end sub

question:
when i click button1, the image(3) is display, then i click button2, but the
image(5) doesn't show up, the image(3) still there, doesn't change to
image(5). Why ?

thanks,
 
Hi Sam,
Can you post the complete code in which you are facing this problem ??

Regards
Ashish M Bhonkiya
 
preliminary:

1.modify web.config accrding to the article

2. add reference to dynamicimage.dll



the code:

Private Sub GetCustomer(ByVal eid As Integer)

Dim cn As New SqlConnection(strcn)

cn.Open()

Dim cm As New SqlCommand("select * from employees where employeeid = " &
eid, cn)

cm.CommandType = CommandType.Text

Dim rd As SqlDataReader = cm.ExecuteReader(CommandBehavior.CloseConnection)

If rd.Read Then

If Not IsDBNull(rd("photo")) Then

Dim img As Byte() = CType(rd("photo"), Byte())

Dim ms As New MemoryStream(img, 78, img.Length - 78)

DynamicImage1.ImageBytes = ms.ToArray()

End If

End If

rd.Close()

cm.Dispose()

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

GetCustomer(1)

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click

GetCustomer(2)

End Sub



questions:

1. when i click button1, the image from customer with id = 1, display in the
web, then i click button2, but image of customer with id = 2 doesn't appear
.. why ?

2. how to use openfiledialog in asp.net ?

thanks,
 
Back
Top