storing Images to the sql table

Hi guys

 I want to add a grid view to my website that displays a picture and a description of a product. I have created my table called products and i have the column(type, Description, Image)  how do i insert an image using the properties window?

Ryan Felton
Cape Town, South Africa

Great programmers are not born. They are compiled
5/4/2009 11:12:28 AM 29906 articles. 0 followers. Follow

9 Replies

Similar Articles

[PageSpeed] 19


Please follow

It will help you.


5/4/2009 12:05:48 PM

 all the data that will be entered, will be done on the table itself. I don't want the image file to be uploaded. I just want a simple url to the file in the table column.

Ryan Felton
Cape Town, South Africa

Great programmers are not born. They are compiled
5/4/2009 1:09:41 PM

 Is there no way of adding a picture into the table without coding stuff out in c# or vb or asp

Ryan Felton
Cape Town, South Africa

Great programmers are not born. They are compiled
5/4/2009 1:44:06 PM

In your image column do you want to have a binary image or a link to the file? What is the type of the Image column?

Beware of bugs in the above code; I have only proved it correct, not tried it.
(Donald Knuth)
5/4/2009 1:57:25 PM

 At the moment it is set as an image

Ryan Felton
Cape Town, South Africa

Great programmers are not born. They are compiled
5/4/2009 2:23:34 PM

I googled your question and found this

Beware of bugs in the above code; I have only proved it correct, not tried it.
(Donald Knuth)
5/4/2009 2:28:38 PM

 stream st = fileUpload1.postedfile.inputStream;

string type = fileUpload.postedFile.ContentType;

string name = fileupload.filename;

int length = fileupload.postedfile.comntentlenght;

byte []b= new byte [length];

int n =,0,b.length);

cmd= new sqlcommand("insert into image.demo values(@name,@image,@type)",cn);

//(cn is sqlconnection)

sqlparameter p2= new sqlparameter ("@name",sqlDbtype.varchar,20);

sqlparameter p3= new sqlparameter ("@image",sqlDbtype.image);

sqlparameter p4= new sqlparameter ("@type",sqlDbtype.varchar,20);

p2.value= name;


p4.value= type;




int u = cmd.executeReader();


retrive image 



cmd= new sqlcommand("select img from imagedemo where id ="+int.parse(request.QueryString[0]",cn);

//dr is sqldatareader

dr= cmd.executeReader();



byte[] b1 = (byte []) dr[0];

response.binarywrite(b1) ;




5/4/2009 2:37:01 PM

BTW, if you're using SQL Server 2005 or up, try using VARBINARY(MAX) for your Image column. Image type is deprecated in newest SQL Server, AFAIK.

Beware of bugs in the above code; I have only proved it correct, not tried it.
(Donald Knuth)
5/4/2009 2:53:44 PM

Similar Artilces:

Transfer the Image Stored in a .gif File to an Image Column in a SQL Server Table
I am trying to use images in my web form and I am trying to write thie executable to help transfer the gifs into the SQL column. Here is my code, I am getting an error. All help is appreciated. Thanks in advance. ----------------------------------------------------------------------------------------- Dim connString1 As String = ConfigurationSettings.AppSettings("connString1") 'bkf-sql1/jHelp Dim cnnConnection As New System.Data.SqlClient.SqlConnection(connString1) Dim rs As ADODB.Recordset Dim mstream As ADODB.Stream Private Sub Page_Load(ByVal s...

I imported a SQL Table into SQL DataBase, But I can not update this table even with SQL Server management Studio
I imported a SQL Table into SQL DataBase, But I can not update this table even with SQL Server management Studio When I change any data on mentioned table above, Red exclamation sign appears left of the record . How can I correct this problem?  Thanks. Try running the UPDATE via Query Analyzer...and see if you get an error.***********************Dinakar NethiLife is short. Enjoy it.***********************...

Storing images in SQL database vs storing images in seperate folder and using URL image path
Hi allCan you store images in a sql database and if so, does it store the images as an image file or does it store it in a binary format reducing the size of the image. If it can be stored in an sql database as a image or a binary format what are the advantages/disadvantages or is it better to store the url in the database and then bind the image holder to the url link in the database. Hi, These two ways are both ok. My suggestion is to store images into sql database if there are no much more images, otherwise, it's better store them into file system because you can store them no mat...

Strange difference between SQL from .Net and SQL within stored proc
Hi, I am trying to fill a DataGrid with random records from my database. It thought I had found a way to randomly select records using SQL. So I built a stored procedure in Access and sure enough, it returns a random set of records. Whe I tried to call this from my app, it kept returning the same set of records. So I copied and pasted the SQL into the app (code below) but it made no difference. Could anyone tell me why this wouldn't work? <%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %><%@ Import Namespace="System.Data" %><%@ Import Namespace="...

HI FRIENDS ! I AM NEW TO VB.NET . MY REQUIREMENT IS ,  I WANT TO UPLOAD IMAGE FILE AND STORE IN THE SQL TABLE PLEASE SLOVE MY PROBLEM . THANKS KAISER     Hi, take a look at this tutorial: There are many of such articles to be found when you use or Grz, Kris.Read my blog. Handy Firefox plugins for web developers.Workaround for non working Mark as answer buttons.  hi !       refer this site

storing url of an image in sql server 2005 table
How to store the url of an image using insert statement in sql server 2005? What is the syntax? You'll just have a normal text column and then insert the URL into it using an absolutely standard insert query....

How to copy sql express tables & stored procedures into remote full sql server 2005
Hi all, I am using Visual web developper 2005 with sql server express 2005 and i have also sql server management studio express. it's all free now . my web site is ready I didn't have problem to upload my site to my hoster. Now I want to upload all my tables and my stored procedure create locally with VWD express How can i do it ? NB: I know i can't design DB (create/modify tables and stored proc) with express edition thank's for your help Hi all, I have my all tables and stored procedures on the remote server and my site is working well but it was very hard to. let me ..., sending mail along with image stored in sql database
Hi All i m able to send a mail with a image saved in image folder my code is :-It is workingDim objMailMessage As New System.Net.Mail.MailMessage With objMailMessage .IsBodyHtml = True.From = New Net.Mail.MailAddress(from) .To.Add(toreceiver) .Subject = "Recommended Product" .Body = email_body() .CC.Add(from)Dim htmlView As AlternateView = AlternateView.CreateAlternateViewFromString(email_body(), Nothing, "text/html") Dim imagelink As New Net.Mail.LinkedResource(Server.MapPath(".") + "\images\baby.gif", "image/gif") 'Dim pa...

Converting a gridView using an Sql Datasource to a gridview who is not using an SQL DataSource
How can i rewrite this page so that i doesnt make use of an SqlDataSource?  <%@ Control Language="C#" AutoEventWireup="true" CodeFile="LoginHistory.ascx.cs" Inherits="Private_UserControls_WebUserControl" %> <html> <head> <%--<link rel="stylesheet" href="BaldwinPortal.css" mce_href="BaldwinPortal.css" type="text/css" />--%> <title>Login History</title> </head> <body style="margin:0 0 0 0;padding:0 0 0 0"> ...

How to save a picture in a SQL image field and how to show a picture from a SQL image field
HI! I am searching now a real long time in the forum and I found a lot of stuff to this topic. But please help me it doesn't work! On my webapplication there is a possibility to save a private picture.If a new user is saved in the database I want to save a fixed picture as startpicture.Dim picturePath As String = Request.ServerVariables("APPL_PHYSICAL_PATH") & "img\anonymous.jpg" Please tell me the way how to save this anonymous.jpg from the picturePath into the database and after that how to display the picture. Thank you! .         ...

Export sql table data into sql
 Dear friends ,   give any ideas for sql table data export into excel in c#   Hi  you can use import /export in sql server enterprise manager, other wise in c# you can bind  sql datas into gridview then convert into excel using following method  string filename = "ExcelFileName.xls"; HttpResponse response = HttpContext.Current.Response; // clean up the response.object response.Clear();response.Charset = ""; // set the response mime type for excelresponse.ContentType = "application/"; response.Ad...

Wanting to take info from one SQL table and update to a seperate SQL table
Anyone have an idea of how I can take information from one table and edit it and insert into another SQL table.  I am using stored procedures and would like to continue to do so. Here is a copy of what I have so far:   <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="mp_Customers" SelectCommandType="StoredProcedure"></asp:SqlDataSource> </div> <h2><strong><font color="#C00000">Please enter a valid account number:</font></strong><...

Can an image stored in a table on a SQL server be displayed (thru a button) along w/its relevant record from a webpage?
If the answer is "Yes", then any information/code would be greatly appreciated! However if the answer is "No" then please read on -Any suggestions, help, input -anything would still be appreciated. Here's a brief overview of the present situation and the application needed to accommodate our future situation. Currently we have an archaic database [DBA] created in FoxPro 2.x that needs to be transformed into a web based (intranet) application in order for the outlying remote offices to retrieve loan information. From my exposure, a DBA in any other form (besides a...

Storing/Retrieving images from SQL 2005 AND Resizing an image
Hi, I have a recent task, where I have to do the following; - Load an image from a SQL 2005 table - Resize the image (keeping the ratio proportional) - Save the resized image to a different table in the same database.   Any help will be appreciated - VB code if possible...   Many thanks.............. Take a read of should get you started. Hope it helps, good luck.RegardsJeremyIf this has helped Please: Don't forget to click "Mark as Answer" on the post that helped you.That way future readers will...

Web resources about - storing Images to the sql table -

Storing Love in a Box - Flickr - Photo Sharing!
i got the box from my neighbor when i accidentally knocked over her vase near her front i guess sometimes, doing something bad can ...

Telstra storing data on behalf of US government
Telstra agreed more than a decade ago to store huge volumes of electronic communications it carried between Asia and America for potential surveillance ...

Ten fruits and vegetables you're storing wrongly
... then wonder what the heck happened to make them shrivel, rot or go limp a few days later. Much of the time, the culprit is the way you're storing ...

Turnbull's doubts on storing digital data
Turnbull's doubts on storing digital data

Google Drive Android app updated with ‘scan’ for storing physical docs, improved UI, and more
Google announced on its Google Drive blog today that it is rolling out an updated Google Drive app for Android that includes a couple notable ...

Long Known for Storing and Sharing, Box Aims to Be More About Doing
It’s becoming ever less accurate to refer to the cloud company Box as a company focused on enterprise file storage. Lately people have been ...

Storing Your Memories In Someone Else’s Brain
Rebecca Schwarzlose considers it “a major benefit of having long-term relationships”: There’s too much information in this world to know and ...

Ditch your wallet by safely storing ways to pay on your iDevice
... Store Gift Cards. Earn Rewards to Save. Key Ring Reward Cards, Circulars, Coupons, Deals, & Shopping Lists Ditch your wallet by safely storing ...

Apple begins storing Russian iCloud data within country, complying with new law - report
Apple is said to have partnered with a Russian data center to host iCloud data for users in that country, responding to a new law that went into ...

iPhone apps storing contact lists just the latest privacy debacle in the mobile industry
Appolicious - Smartphones and mobile applications entertain, inform and keep us connected in ways we could not even fathom just a few years ago. ...

Resources last updated: 12/14/2015 8:52:18 AM