• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2209
  • Last Modified:

save image file in ASP 2.0 using C#

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
siddhuoops
Asked:
siddhuoops
1 Solution
 
surajgupthaCommented:
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
 
SameerJagdaleCommented:
do you mean, you want to save imagepath in a table and actual image in folder..
0
 
siddhuoopsAuthor Commented:
yup
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
surajgupthaCommented:
Folders in the SQL database is not possible as far as i know if thats what you mean.
0
 
siddhuoopsAuthor Commented:
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
 
surajgupthaCommented:
Set the ImageControl's Image property to Image object that you constructed
0
 
Vee_ModCommented:
Force accepted.
Vee_Mod
Community Support Moderator
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now