asp .net / sql / image data type question

M

mattmerc

Hi all,

I have an web application where security staff can enter incidents.
Part of the form allows the user to describe person(s) involved in an
incident. My company just so happens to have a sql database will all
employees as well as a picture. I have created a lookup tool so someone
can enter in a first or last name and then get a list of matching
employees. They can then select which one from the datagrid and all the
information I can pull is autopopulated on the form. Pretty standard so
far, eh? Well, the problem is moving the picture from the employee sql
database (which I do not manage or have control of!) to my incident
database.

When a user of my application searches a person he/she gets a datagrid
with the choice to select the person or see the picture. If they choose
to see the picture then, I have a hidden image tag with its source set
to a page that does this:

-------------------------------------

Dim conMatt_I3 As SqlConnection
conMatt_I3 = New SqlConnection("HIDDEN")
conMatt_I3.Open()

Dim cmdLoadAttachment As SqlCommand
Dim dtrLoadAttachment As SqlDataReader

cmdLoadAttachment = New SqlCommand ("SELECT * FROM mmobjs WHERE
empid='" & session("empid") & "'", conMatt_I3)
dtrLoadAttachment = cmdLoadAttachment.ExecuteReader()
dtrLoadAttachment.Read()

Response.Buffer = True
Response.ContentType = "Image/BMP"
Response.BinaryWrite(dtrLoadAttachment("lnl_blob"))

dtrLoadAttachment.Close()
---------------------------------------
This is an easy was to display the picture. My problem is capturing
this image data and writing it back to my sql database. I have tried
defining a byt variable and setting it equal to the output of the
datareader that loads the image data, but this does not work. When I
look at code used to upload files I see the length of the file is
usually needed. I have the code to do this when a user is browsing for
a file and trying to upload it. Unfortunately, that is not what I am
trying to do. I need some asp .net / vb .net / sql code to read the
image column from a database I only have read access to (there is no
infomation on size, filetype, etc... just image datatype) and save it
as image datatype to my database so I can display it again later.

Hopefully, I made some sense! Thanks all!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,609
Members
45,253
Latest member
BlytheFant

Latest Threads

Top