Displaying an image...

06-18-2002, 08:45 AM
My next problem. I'm having difficulty finding information on displaying images on a web page. I have a database that contains 158000 records one of the fields is CARDPATH. This field contains the physical path (on the server) to an image that corresponds to a record (unique) in my database.

Example record...
UNIQUE = 20397
CARDPATH = e:/cards/bio/st-sw/20397.jpb
ENTRY = stuart biography henry county 1856

I wrote a program in VB that works great for editing, adding, and assigning the cardpath to fields when new records are added to the database. I then converted the database to SQL. My current ASP code allows the user to enter a record number and then diplays the fields. Here is the code:


<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 2</title>

Dim SearchThis
SearchThis = Request.QueryString("iRecordId")

If IsNumeric(SearchThis) Then

Dim cnnDatabase, rstDatabase, dtbDatabase
cnnDatabase = "Driver=SQL Server;server=DIGITAL;database=gen_cards_sql;uid=cinnamon;pwd=sinnamon"
Set rstDatabase=Server.CreateObject("ADODB.Recordset")
dtbDatabase = "SELECT unique,cardpath FROM Cards WHERE [unique]"= & SearchThis & ";"
rstDatabase.Open dtbDatabase, cnnDatabase, adOpenStatic

If NOT rstDatabase.EOF Then
Response.Write "record = " & rstDatabase.Fields("unique") & "<BR>"
Response.Write "cardpath = " & rstDatabase.Fields("cardpath") "<BR>"
Response.Write "entry = " &rstDatabase.Fields("entry")
Response.Write "Record not found"
End If

Set rstDatabase = Nothing
Response.Write "Invalid input"
End If



What I really need is to be able to pull up the record by the unigue field (that part is working). View the image and be able to edit the entry field. And lastly, save the edited record.

I know that was alot of information but I'm trying to be a thorough as possible. Anyway, can someone point me in the right direction for displaying the image when the record number is entered?


Derek Stone
06-18-2002, 12:51 PM
You can only display images that are located under the root path of your web server. If they're located somewhere else the client's browser won't be able to access them to display. With this said you'll need to copy the image files to a directory under your webservers root, either all at once or as requested by a client.

Good Luck

06-18-2002, 08:34 PM
You can also also virtualize directories that are not within the standard C:\inetpub\wwwroot file path. This can save you the hassle of transporting files. The webserver knows where to reference the files in the local system structure, while the directory appears virtually to the web users.

Ex: The directory path D:\pics could be virtualized on the server as pictures. A browser could then pull it up as yourwebaddress.com/pictures and you would still access it from D:\pics.

As for the display aspect of your poblem, you are on the right track with the unique ID. You would use this to reference all of the desired information.

RS.Open _
"SELECT * " & _
"FROM [tblYours] " & _
"WHERE [UniqueID]='" & Request("txtUniqueID") & "'", adoConWhere txtUniqueID is the FORM TEXT box where the user enters the ID.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum