473,225 Members | 1,418 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,225 software developers and data experts.

Pictures on SQL Server

Hello

I'am building an web application that enable users to get data stored in a
SQL Server.

My problem is pictures. How can I display pictures stored in SQL Server - In
the old days, I took the picture and saved it into disk and loaded from
here...

Kind regards

Johnny E Jensen
Nov 19 '05 #1
4 3052
This may help (one idea)
http://www.samspublishing.com/articl...?p=377078&rl=1

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
"Johnny Emde" wrote:
Hello

I'am building an web application that enable users to get data stored in a
SQL Server.

My problem is pictures. How can I display pictures stored in SQL Server - In
the old days, I took the picture and saved it into disk and loaded from
here...

Kind regards

Johnny E Jensen

Nov 19 '05 #2
sorry for my english :-)
this example it's for access but you can convert to sql server

<script runat="server" Language="C#">
void Page_Load(Object o,EventArgs e) {
string db, strsql, idx;
idx = Request.QueryString["id"];
if (idx = =null) idx = "1";

db="immagini.mdb";
OleDbConnection myconnection = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source="+Request.MapPath(db));
myconnection.Open();

strsql = "Select image,name,contenttype FROM Tabella1 where id=" + idx;
OleDbCommand mycommand = new OleDbCommand(strsql,myconnection);
OleDbDataReader re = mycommand.ExecuteReader();

if (re.Read()) {
Response.Clear();
Response.ClearContent();
Response.ContentType = re["contenttype"].ToString();
Response.BinaryWrite((byte[])re["image"]);
}
else
Response.Write ("nothing image for this ID");

re.Close();
myconnection.Close();
}
</script>
in the page:
<img src="view_image.aspx?id=1">
good luck

byez
imperugo (exCartman)
myblog : http://imperugo.blogspot.com


"Johnny Emde" <em**@emde.dk> wrote in message
news:e3**************@TK2MSFTNGP12.phx.gbl...
Hello

I'am building an web application that enable users to get data stored in a
SQL Server.

My problem is pictures. How can I display pictures stored in SQL Server -
In the old days, I took the picture and saved it into disk and loaded from
here...

Kind regards

Johnny E Jensen

Nov 19 '05 #3
You'll need a special page (or an HTTP Module that simulates a page) to
retrieve the image from SQL Server so an Image control on a page can
reference it.

These articles contain most (if not all) of the details you'll need.
http://SteveOrr.net/articles/EasyUploads.aspx
http://SteveOrr.net/articles/ImproveYourImages.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Johnny Emde" <em**@emde.dk> wrote in message
news:e3**************@TK2MSFTNGP12.phx.gbl...
Hello

I'am building an web application that enable users to get data stored in a
SQL Server.

My problem is pictures. How can I display pictures stored in SQL Server -
In the old days, I took the picture and saved it into disk and loaded from
here...

Kind regards

Johnny E Jensen

Nov 19 '05 #4
Thangs! ( that was quick reply )

Both esamples works fine - if i would have the picture shown at the current
page - I'am building a
web user control that holds a control to display picture ie. Image Control.
And its very important
that the picture are showed in that control.

Please more help - i love examples....

Kind regards
Johnny E Jensen

"imperugo" <ug**********@dgsworld.it> wrote in message
news:et**************@TK2MSFTNGP15.phx.gbl...
sorry for my english :-)
this example it's for access but you can convert to sql server

<script runat="server" Language="C#">
void Page_Load(Object o,EventArgs e) {
string db, strsql, idx;
idx = Request.QueryString["id"];
if (idx = =null) idx = "1";

db="immagini.mdb";
OleDbConnection myconnection = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source="+Request.MapPath(db));
myconnection.Open();

strsql = "Select image,name,contenttype FROM Tabella1 where id=" + idx;
OleDbCommand mycommand = new OleDbCommand(strsql,myconnection);
OleDbDataReader re = mycommand.ExecuteReader();

if (re.Read()) {
Response.Clear();
Response.ClearContent();
Response.ContentType = re["contenttype"].ToString();
Response.BinaryWrite((byte[])re["image"]);
}
else
Response.Write ("nothing image for this ID");

re.Close();
myconnection.Close();
}
</script>
in the page:
<img src="view_image.aspx?id=1">
good luck

byez
imperugo (exCartman)
myblog : http://imperugo.blogspot.com


"Johnny Emde" <em**@emde.dk> wrote in message
news:e3**************@TK2MSFTNGP12.phx.gbl...
Hello

I'am building an web application that enable users to get data stored in
a SQL Server.

My problem is pictures. How can I display pictures stored in SQL Server -
In the old days, I took the picture and saved it into disk and loaded
from here...

Kind regards

Johnny E Jensen


Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: NotGiven | last post by:
I am researching the best place to put pictures. I have heard form both sides and I'd like to know why one is better than the other. Many thanks!
0
by: JakeC | last post by:
Hey all, I'm currently redesigning a website that a friend and I started about a year ago. It is a daily surf report so when choosing the best script/language to use for the new design, I found...
6
by: Nutshell | last post by:
Hi, I created a web page which contains table. I use table cells to display a picture using <img src>. The problem is that some pictures are not being fully displayed, only a quarter of the left...
13
by: gooze | last post by:
Hello I am working on an applicaion that shows several pictures on a webpage. These pictures are saved in a MySQL DB as BLOB. I noticed, that the web server suffers in its performance by...
13
by: Jim Carlock | last post by:
I have over a hundred pictures I would like to present. Is it practical to create and parse an array of pictures, picture paths, et al using server-side scripting to accomplish this? I...
4
by: Jofio | last post by:
I am developing a picture gallery - pictures of landscapes and various other subjects. My site has a left panel consisting of thumbnails of pictures which when clicked displays the corresponding...
9
by: C.Joseph Drayton | last post by:
Hi All, I have a web site I am developing, and have a question. I would like members to be able to upload pictures. Do you think they should be saved as individual files or should they be put...
8
by: cbmeeks | last post by:
I am writing my own family photo sharing site that I hope to take public (like so many others). Anyway, currently, when the user uploads a picture, I store the picture outside my htdocs folder and...
4
by: Zeljko Bilandzija | last post by:
Hy, could someone help me in this: In design mode, i want to put pictures in database. I made column named pics, and its type as image. How can I put pictures or some address of these pictures...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.