View Full Version : Reading Binary Image from Database
noora
07-07-2010, 09:11 AM
Hi, i have an sql database the store the images as a binary data, and i am using some code in asp to view the images in html in img tag, and i tried to change the code of images Slideshow to read from the database but its not working for me
could you please help me, its urgent
jscheuer1
07-07-2010, 09:20 AM
We would need to see the asp code for the img tag and the javascript code for the slide show. Please post the asp code and link to the javascript code.
noora
07-07-2010, 10:56 AM
ok this is my code
for the page that contain the slideshow
----------------------------------------------
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="fadeslideshow.js">
</script>
<script type="text/javascript">
var mygallery=new fadeSlideShow({
wrapperid: "fadeshow1",
dimensions: [250, 180],
<%
//connect to the database
rs.open "select * from mcontents where ctype = 'image'",cn
%>
imagearray: [
["<img src=../../ShowDataFile.asp?rid=<%=rs('rid')%>&ftype=file2 />", "", "", "<%=rs('title')%>"]
],
displaymode: {type:'auto', pause:2500, cycles:0, wraparound:false},
persist: false,
fadeduration: 500,
descreveal: "peekaboo",
togglerid: ""
})
</script>
</head>
<body>
<div id="fadeshow1"></div>
</body>
------------------------------------------
and for the ShowDataFile.asp the view the Binary image contain the following
-------------------------------------------
if filetype = "file2" then
Response.ContentType = Rs("ContentType2")
Response.BinaryWrite Rs("BinaryData2")
-------------------------------------------
I know that i am writting something wrong
but i dont know how to fixe it please help me
jscheuer1
07-07-2010, 02:18 PM
I'm not real up on asp, though I'm not exactly a beginner either. I asked to see an img tag because that would give me a better idea of what's going on. You didn't do that, but this:
<img src=../../ShowDataFile.asp?rid=<%=rs('rid')%>&ftype=file2 />
Looks like it might be what I need.
Now, in the end we want the page's served code to be what it would be if we had hard coded everything according to the instructions from the demo page for this script. This is easily seen by using the browser's 'view source' when viewing the page.
Here:
imagearray: [
["<img src=../../ShowDataFile.asp?rid=<%=rs('rid')%>&ftype=file2 />", "", "", "<%=rs('title')%>"]
],
We want to see something like so:
imagearray: [
["somepath/someimage.jpg", "", "", "some description"]
],
But we are going to need more than just one of the highlighted line, and all lines like that should point to different images and all but the last one needs a comma at the end. Asp has a way of doing things in a loop while something is true - say, while a counter that gets incremented each pass of the loop is under a certain amount. So you are going to have to do something like that to make more than one. And figure out a way to end up without a comma at the end of the last one (having a comma at the end of the last one is only a problem in some IE browsers in some modes, or all IE browsers in other modes).
Before you figure that out you need to make the output of each of these lines match the template of the highlighted line so as to fit the requirements of the script. That would probably be like so:
["../../ShowDataFile.asp?rid=<%=rs('rid')%>&ftype=file2", "", "", "<%=rs('title')%>"],
noora
07-08-2010, 06:07 AM
Its working now :)
Thank you very much
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.