[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

save image file in ASP 2.0 using C#

Posted on 2007-11-21
8
Medium Priority
?
2,208 Views
Last Modified: 2012-05-05
How could I save an image file in Sql server 2005? In my application, I want to save the image in a folder and then the directory in the sql server 2005. So, in my table, there will be sth like this ~/images/header1.jpg
and the header.jpg should go to images folder in my application.

Could somebody help?
0
Comment
Question by:siddhuoops
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 21

Expert Comment

by:surajguptha
ID: 20329262
You can store files as BLOBS in the database. In the database it wont be stored in folders but as its own internal representation
0
 
LVL 13

Expert Comment

by:SameerJagdale
ID: 20333019
do you mean, you want to save imagepath in a table and actual image in folder..
0
 

Author Comment

by:siddhuoops
ID: 20344492
yup
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 21

Expert Comment

by:surajguptha
ID: 20345977
Folders in the SQL database is not possible as far as i know if thats what you mean.
0
 

Author Comment

by:siddhuoops
ID: 20351380
I was able to save image in a sql database but now how would I display that image in an image control?
This is how I saved the image.
                byte[] sponsorimage = new byte[sponsorupload.PostedFile.ContentLength];
                HttpPostedFile Image = sponsorupload.PostedFile;
                Image.InputStream.Read(sponsorimage, 0, (int)sponsorupload.PostedFile.ContentLength);

                scon = new SqlConnection("Data Source=sadev01;Initial Catalog=Hometourads;Persist Security Info=False;User ID=sa_sql;Password=str@teg1K@m3r1ka");
                scmd = new SqlCommand("SA_STPR_Hometourads_Insert", scon);
                scmd.CommandType = CommandType.StoredProcedure;

                scmd.Parameters.AddWithValue("@sponsor_logo", sponsorimage);
                scon.Open();
                scmd.ExecuteNonQuery();
                scon.Close();
            }

            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            finally
            {
                scon.Close();
            }

Now I want to display this image in an image control. What should I have to do in order to display it?
0
 
LVL 21

Accepted Solution

by:
surajguptha earned 2000 total points
ID: 20359662
Set the ImageControl's Image property to Image object that you constructed
0
 
LVL 1

Expert Comment

by:Vee_Mod
ID: 20516351
Force accepted.
Vee_Mod
Community Support Moderator
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question