In one of my previous posts i showed you you how to store a image SQL SERVER database. This time im going to show how to preview it back.
So lets move on...............
First of all lets write a method to get the image form the database.
Public Function getImage(ByVal
CLI_ID As Integer) As Byte()
Dim img As Byte() = Nothing
Dim cmd As New SqlCommand()
cmd.Connection = con
cmd.CommandType = CommandType.Text
cmd.CommandText = "SELECT image FROM Image WHERE Customer_id=@Customer_id"
cmd.Parameters.Add("@Customer_id", SqlDbType.VarChar).Value = CLI_ID
img = cmd.ExecuteScalar()
Return img
End Function
Then add this code to your code behind of the aspx page
Dim img As Byte() = getImage(clientID)
If Not img Is Nothing Then
Response.BinaryWrite(img)
End If
So thats all you have to do.
Hope his will help you guys
Cheers...........:)
No comments:
Post a Comment