Store IMAGES Into Database

Feb 26, 2006

I want to store IMAGE into Database So can any one tell me what's the command for that ?



like my image name is hello.jsp



command means the query like ( Select * from tableNAme )



Like thins pl help me & tell me What datatype should i use for that ?



Thaks for your help in advance



Have a Good Day

Harsh

View 1 Replies


ADVERTISEMENT

How Could I Store Images In A Database??!!

May 8, 2006

hi everybody,can anybody help me out by telling me how could I store images in a database, and how to insert new images at run time to a database and thanks

View 1 Replies View Related

How To Store Images In A Database Table

Jan 14, 2007

Hello All,
My question is how to store images in a database table (in SQL Server), and how to retrieve them?...
 Thanks,  
 

View 2 Replies View Related

How Can I Store And Retrieve Images From A Database

Mar 23, 2008

hi,
i would like to store images in my database and retirve them aswell. i have looked at examples on the net but i am finding it hard to follow and undertsand them, can anyone please give me adivse on how i can do this. i have alrady created my table in my database which has 4 fields pictureID, pictureContent, pictureType and pictureSize but i dont know where to go on from here. i want to do it in vb aswell.
please any help and advise would be much appreciated as i am stuck,
thank you

View 20 Replies View Related

Should I Store Images In The Database Or The Filesystem?

Jun 7, 2006

Images, PDFs, word documents, etc..., will it affect the performance of my sql if I stored them in it as blob objects? Or it's better to use the filesystem instead and just store file paths in my sql?
thanks in advance

View 1 Replies View Related

Can You Store Images In A Database Or Table?

Sep 24, 2001

Can you store images in a database or in a table, or do you have to only store the image path/name in the database while the image is in another folder? IF anyone knows, please share with me. Thanks.

View 2 Replies View Related

Images - Store In A Database Or File System?

Jun 19, 2007

I have recently designed and built my first database using SQL server 2005 express. I have included an image (BLOB) column in one of the database tables. This is a bad idea according to some experts, and some say it is OK!


I am currently carrying out a trial with just 3 pictures via Visual Basic 2005 express forms, and there is no problem so far as the images are displayed for each record. But I anticipate between 300 - 1000 images for the table, and this could pose real problems for SQL server 2005 express and Visual Basic 2005 express, I guess.


I have just been reading that the cost of storing large images in the database is too high! I have also read it's better to store images (BLOB) into the file system because it is cheaper to store them no matter how many there are.


But the question is how I can reference an image in this path: C:PictureProductGrocery0052745.jpg in the database table, so that when I select a record Visual Basic 2005 forms the image is displayed accordingly, similar as when stored directly in the database table? Your help very much appreciated.

View 3 Replies View Related

How To Store Images In The Image Field In A Sql Server Database

May 6, 2008

hi can anyone tell how to use the image field and add an image in a database. i'm using visual studio web developer express edition 2008 and i want people who visit my website to be able to see the table and the images associated with some of the rows in the table
 
Thanx Taryn

View 2 Replies View Related

How To: Store And Retrieve Images In A Database As A Byte Array.

Feb 28, 2008

I€™ve inherited a project from one of the guys on our team who will be out sick for a while. He developed two for marshaling data between System.Drawing.Image and System.Byte(). He€™s storing the byte array data in a database image field.

I€™ve retrieved the byte array data from his database image fields and have successfully converted them to images using his ConvertByteArrayToImage method below. I have also converted and image to a byte array with his ConvertImageToByteArray method below and succfully stored the data in a database image field. However, when I retrieve the byte array data that I stored in the database the last line in his ConvertByteArrayToImage method throws an exception (Parameter is not valid). I€™ve not been able to find a working copy of his code that€™s storing the byte array data. Does anyone see anything I€™m overlooking?

Imports System.Drawing
Imports System.IO

Public Sub InsertImage(ByVal pFilename As String)

Try

Dim lImage As Image
Dim lBA() As Byte
Dim lSQL As String
Dim lQuery As Alcon.SQLServer.Database.clsQuery
Dim lParameters As New Alcon.SQLServer.Database.clsParameters

lImage = Image.FromFile(pFilename)

ConvertImageToByteArray(lImage, lBA)

' Initialization
lQuery = New Alcon.SQLServer.Database.clsQuery(mConnection)

lSQL = ""
lSQL += "INSERT INTO [TBL_PCL_LENS_DATA]("
lSQL += "[SerialNumber], "
lSQL += "[ProcessedDate], "
lSQL += "[CartonLabelImage]) "
lSQL += "VALUES ("
lSQL += "@SerialNumber, "
lSQL += "@ProcessedDate, "
lSQL += "@CartonLabelImage "
lSQL += ")"

lParameters.Add("@SerialNumber", SqlDbType.VarChar, ParameterDirection.Input, mSerialNumber)
lParameters.Add("@ProcessedDate", SqlDbType.DateTime, ParameterDirection.Input, Now)
lParameters.Add("@CartonLabelImage", SqlDbType.Image, ParameterDirection.Input, lBA)

' Execute query
lQuery.Execute(lSQL, lParameters)

Catch ex As Exception
Throw
End Try

End Sub

ConvertByteArrayToImage(ByVal pBA() As Byte, ByRef pImage As Image)

Try

' Declaration
Dim lMS As MemoryStream

' Initialization
lMS = New MemoryStream(pBA, 0, pBA.Length)
lMS.Write(pBA, 0, pBA.Length)
lMS.Position = 0

' Create image
pImage = Image.FromStream(lMS, True)

Catch ex As Exception
Throw
End Try

End Sub

ConvertImageToByteArray(ByVal pImage As Image, ByRef pBA() As Byte)

Try

' Declaration
Dim lBM As Bitmap
Dim lBR As BinaryReader
Dim lMS As New MemoryStream

' Initialization
lBM = New Bitmap(pImage)
lBM.Save(lMS, Imaging.ImageFormat.Png)
lBR = New BinaryReader(lMS)

' Create byte array
pBA = lBR.ReadBytes(lMS.Length)

Catch ex As Exception
Throw
End Try

End Sub

View 1 Replies View Related

How To Store Images?

Oct 10, 2006

hi experts,
how can i store images in database? and how can i call them back?
please give me in detail.


thank you very much

View 3 Replies View Related

Can Varchar(max) Store Images In Sql ?

Jun 18, 2007

If you serialize the image into a string ?  If you want to save a byte array to a string, do you have to use a base64 encoded string ?

View 1 Replies View Related

How I Can Store & Retrive Images

Aug 14, 2001

hi,

i would like to know how i can store and retrive images from SQL server.
I will be happy if i have been explained with some examples.

View 1 Replies View Related

Store Images In SQL Server Using ASP.net

Mar 9, 2004

Hey guys,

Can someone guide me how to store images in SQL Server using ASP.net?


Thanks
Lawrence

View 4 Replies View Related

What Is The Better Way To Store Images In MSSQL 2000?

Jan 2, 2004

hi guys, are there any official or some sort of documents to talk about the advantages and disadvantages of storing image in the SQL's Image datatype field or storing the pointer to the image file? i have lots of static images (no more than 1MB each) that requires little updating and i need to retrieve them constantly. i am really struggled here on which method i should store the images: to store the images as Image datatype in SQL or save them as files and store the paths to the files. i would like to know, in my case, would there be any performance and efficient difference on using either method?
naturally, i'd think the 1st method seems like a better solution. it's easier to back up and it protects integrity. But at the same time, i am not sure if the constant inserting and retrieving of images will affect the performance? also, i want to share the images and may create a ticker thing (using JavaScript) to display the images on the web page randomly and it seems like the 2nd method is easier to program. if you were me, which method would you use and why? thanks!

View 1 Replies View Related

Looking For Opinions.....want To Use SQL Server To Store Images

Apr 25, 2006

I have a client who wants to be able to upload images to his website for his customers to access.  It will probably max out at 100 images a month...so not a huge amount of data.  I am using asp.net 2.0 and SQL Server 2005. 
Does anyone have thoughts or opinions on why I should or should not take this approach?

View 3 Replies View Related

How Do I Store Images (like GIFs) In Sql Server 2005?

Jan 2, 2007

I have a web server running fine together with an sql 2005 db. I use asp as my web server programming language and want to be able to display images that are stored in the database.

My question of course is how do I put images, for example an image called "image1.gif" into the database?

After having stored the images in the db, I guess that the are displayed on my web pages the same way as all text information (by writing something like <%=rs("image_column")%> ).... Anyway first I need help with how to store imgs in the database...

View 6 Replies View Related

Images - Type Of Values To Store Pics

Apr 21, 2013

What is the type of values I have to use to tell the database to store pics?

View 4 Replies View Related

URGENT:How To Store And Retrive Images From SQL SERVEr 2005 In Asp.net 2.0

Jul 2, 2006

 i am working on a uni project based on orkut and is having dfficulty in storing and retrieving images..
can anybody please guide me...
thanx
 

View 1 Replies View Related

Photos In SQL Server: Store As Images Or Strings With Path && Filename?

Apr 4, 2008

Hi, for my photo album database I'm trying to decide whether to store the actual photos as images in the db or whether to leave them in file directories with just the path & filename in the db. As a beginner in this field I don't know how either of these options compare (e.g. in terms of performance, complexity, flexibility and maintainablity) so any advice on the pros and cons of each would be appreciated.

View 5 Replies View Related

Store And Retrive Images (JPEG/PNG/GIF/JPG) In Sql Server Express 2005 In ASP.net Through C#

Jul 17, 2007

Hi friends



plese help me for my little things.



I m student and develop a website. i want to know how images /pics and video and audio files are store in Sql server2005 database. and ya i want to store whole file not just its address.

i using asp page like uploadImage.aspx in that i put UploadFiles control now i m confuesd to storing Images so plese help me and give code or some good easy trick at my level



And once store image or video and audio file in sql database then after how i used in my asp.net page. which control i wish to used for this files so plese this also slove it. give also code or any easy trick for fullfil my task..



i hope u all help me

Thanx in advance to u all friends

View 1 Replies View Related

How To Insert Images In The Data Type (BLOB - Images)

May 23, 2003

I am having a problem with MMSQL BLOB with VB, Sorry to say I am new in Programming using VB 6 and MSSQL and I have never touch BLOB in my live.

I just wish anyone could give me any ideal, like, white pages, or manual on how do I insert BLOB data (Images) to MSSQL 2000 database using VB 6. I need to know exspecially the VB Code and the SQL Portion if you have a store procedure code for that it will be nice.
:confused:

View 3 Replies View Related

Images With A Data Value Of A URL, I.e. Web Images, Appear In The Designer But Not In The Actual Report.

Feb 9, 2007

The URL address is for example http://backup/pics/19980.jpg

On the report when I right click on an image the URL is http://localhost/reportserver

I do not understand what is going on. Please help.

Many thanks,

Nic

View 1 Replies View Related

Retrieving Images From Database

Jun 10, 2008

Hi.
I've been traling the forum and the internet for a striaghtr forward solution on this.
I'm trying to do what loads of people have already achieved: retrive images from an SQL database.
I have successfully uploaded inages to an "iamges" table, storing the image as SQL type "image", also storing size, type, description, name etc.
I want to be able to read one or more of these images (and other data) back from the table.
I'm using C#, ASP NET 2.0, SQL,
Any examples I've found needed a lot of tweaking, and for some reason or other didn't work!
Please don;t just pose yet another URL to an example - I've probably tried it and failed already.
I don't mind if I display the images in a GridView or just within an aspx page.
Ideally I'd be able to dispaly a few images on a page.
I know how to read and display the rest of the data in the "images" table.
Can anyone help please?
Do you need more info?
Thanks in advance,
Garrett
 

View 4 Replies View Related

Inserting Images Into Database

Oct 13, 2005

Hi,Recently I was asked to insert images into the database as a part of my module,can someone help me out on this, How can I insert images and retrieve the same from databaseSandhya

View 1 Replies View Related

Storing Images In The Database???

Sep 22, 2004

hello ... i have a project this semester and i had to study is storing images in a database ( using Microsoft Access ) is good or bad ? so any one could tell me the advantages and the disadvantages please ...
thanks
bye

View 5 Replies View Related

Storing Images In A Database

Oct 6, 2005

An odd question from me, I know, but this time, I assure you a twist.

I have a group that wants to store images in either a database or a file share, in order to make a certain website able to run on a load balanced web farm. These images are around 1KB each in size, and have a lifespan of exactly one use (think of graphs). I went a-googling, and found no shortage of articles that say "don't do it, but here's how you can do it", but I did not find any real hard statements as to why to not do it. Needless to say, this is hurting the case for not putting these images in the database. I have found an article that says images over 8KB will have worse performance, but I can not use that factoid here. For the moment, I have the developers leaning toward the fileshare, because they will be writing transaction logs all day, which will be more work than the fileshare needs to do....I think. The best I can do, is cut the text/image datatype overhead, and have them create the table as varbinary(2000), but even then, I don't like the look of the idea.

Anyone out there have good articles/whitepapers that detail the differences between writing single-use images to a fileshare vs. a SQL database? <baiting=blatant>Failing that, do any of the Microsoft development team have an opinion?</baiting>

Alternatively, what is the general opinion of keeping session state information in a database (because I bet that will be my next battle). I see .NET includes a session state server, but not being a programmer, I can not create an opbjective test.

View 5 Replies View Related

Need To Upload Images To Database - Help

May 30, 2008

Hia,

We have a simple table which we need to store logo's for a website. The table looks like this:

CLIENTLOGO (Tablename)
id (Bigint) (PK) - NOT NULL
StoredImage (Image) - NOT NULL
ImageSize (Integer) - NULL

Im not an expert on sql sorry!

I have two problems,
1. I need to upload some logo's (they are gif's if thats important)
2. I need to store the image size

I don't have a clue how to do 2 but ive tried the following for 1 but it doesnt seem to work

Insert into CLIENTLOGO (id, storedImageTablename)
Values (1, 'c:ClientLogo1.gif')

Can somebody help, im really confused about this one

View 4 Replies View Related

Binary Images Within A Database

Dec 31, 2007

Hello folks,

I am going to try to explain this as best I can. First off I have a single database within SQL 2005 and the table within the database has a field for binary image data. Currently this database has about 4,000 image records.

What I would like to do is recompress each of the images with new compression software called Déjà vu. What needs to happen in my mind is, pull the current binary data into the compression software, compress the image, then upload the binary data back into the same record as a batch command.

My question is can I do something like that via command line? Or is this something that will require rebuilding the entire database from the ground up? I like having the data all in one database for ease of
maintenance and intergration with other databases I am working with, so I dont want to just link the images.

View 1 Replies View Related

Viewing Images Stored In Sql Database!?

Jul 10, 2006

Hi,
I want to view the images that are stored in a sql database. I am using VS2005. When I open server explorer and drill down to the dbase tables and the click on the show table data option the table is displayed in a new window.
when I open a table that stores images only a tag saying that the cell contains binary data is displayed. There doesn't seem to be any way to display the actual image and therefore edit the image. I can manipulate textual data directly in the database table...how do I edit graphics?
Thanks!

View 3 Replies View Related

Images In DataBase Or Server Folder?

May 9, 2007

hi everyone,I'm currently developing a website and have a lot of images to use there(obviously :P), until now I have in some tables in my sql server db where exists a column which stores the path to: 'image folder + filename'And my question is: what are the advantages of using  binary images in database instead of this approach to the problem, i.e., having images stored in a server folder.Thanks in advance. 

View 2 Replies View Related

Upload Images And Text To Database

Mar 22, 2008

 I have a form that inserts text and also allows the user to upload 3 images.  I have the text part working, but can't figure out how to get the images uploaded. Here is the form.  I just inserted the 3 upload controls in the form and in the datasource to show what I am trying to do.  If anybody can help me I appreciate it.   1 <h3><br />Add Listing</h3><hr />
2 <div style="margin:auto;">
3 <table align="center" >
4 <tr>
5 <td align="right">
6 Address:</td>
7 <td>
8 <asp:TextBox ID="TbAddress" runat="server" MaxLength="62" Width="250px"></asp:TextBox> </td>
9 </tr>
10 <tr>
11 <td align="right">
12 City:</td>
13 <td align="left">
14 <asp:TextBox ID="TbCity" runat="server" MaxLength="62" Width="250px"></asp:TextBox></td>
15 </tr>
16 <tr>
17 <td align="right">
18 State:</td>
19 <td align="left">
20 <asp:DropDownList ID="DdState" runat="server">
21 </asp:DropDownList>
22 </td>
23 </tr>
24 <tr>
25 <td align="right">
26 Zip Code:</td>
27 <td align="left">
28 <asp:TextBox ID="TbZipCode" MaxLength="15" Width="75px" runat="server"></asp:TextBox>
29 </td>
30 </tr>
31
32 <tr>
33 <td align="right">
34 Listing Price:</td>
35 <td align="left">
36 <asp:TextBox ID="TbListingPrice" runat="server" MaxLength="30" Width="125px"></asp:TextBox></td>
37 </tr>
38 <tr>
39 <td align="right">
40 Taxes/Half:</td>
41 <td align="left">
42 <asp:TextBox ID="TbTaxes" runat="server" MaxLength="30" Width="125px"></asp:TextBox></td>
43 </tr>
44 <tr>
45 <td align="right">
46 Subdivision:</td>
47 <td align="left">
48 <asp:TextBox ID="TbSubdivision" runat="server" MaxLength="60" Width="225px"></asp:TextBox></td>
49 </tr>
50 <tr>
51 <td align="right">
52 County:</td>
53 <td align="left">
54 <asp:TextBox ID="TbCounty" runat="server" MaxLength="60" Width="225px"></asp:TextBox></td>
55 </tr>
56 <tr>
57 <td align="right">
58 School District:</td>
59 <td align="left">
60 <asp:TextBox ID="TbSchoolDistrict" runat="server" MaxLength="60" Width="225px"></asp:TextBox></td>
61 </tr>
62 <tr>
63 <td align="right">
64 Bedrooms:</td>
65 <td align="left">
66 <asp:DropDownList ID="DdBedrooms" runat="server">
67 </asp:DropDownList>
68 </td>
69 </tr>
70 <tr>
71 <td align="right">
72 Bathrooms:</td>
73 <td align="left">
74 <asp:DropDownList ID="DdBathrooms" runat="server">
75 </asp:DropDownList>
76 </td>
77 </tr>
78 <tr>
79 <td align="right">
80 Living Space:</td>
81 <td align="left">
82 <asp:TextBox ID="TbLivingSpace" runat="server" MaxLength="30" Width="125px"></asp:TextBox></td>
83 </tr>
84 <tr>
85 <td align="right">
86 Stories:</td>
87 <td align="left">
88 <asp:DropDownList ID="DdStories" runat="server">
89 </asp:DropDownList>
90 </td>
91 </tr>
92 <tr>
93 <td align="right">
94 Building Style:</td>
95 <td align="left">
96 <asp:TextBox ID="TbBuildingStyle" runat="server" MaxLength="60" Width="225px"></asp:TextBox></td>
97 </tr>
98 <tr>
99 <td align="right">
100 Year Built:</td>
101 <td align="left">
102 <asp:TextBox ID="TbYearBuilt" runat="server" MaxLength="30" Width="125px"></asp:TextBox></td>
103 </tr>
104 <tr>
105 <td align="right">
106 Bastment:</td>
107 <td align="left">
108 <asp:DropDownList ID="DdBasement" runat="server">
109 </asp:DropDownList>
110 </td>
111 </tr>
112 <tr>
113 <td align="right">
114 Heating:</td>
115 <td align="left">
116 <asp:DropDownList ID="DdHeating" runat="server">
117 </asp:DropDownList>
118 </td>
119 </tr>
120 <tr>
121 <td align="right">
122 Cooling:</td>
123 <td align="left">
124 <asp:DropDownList ID="DdCooling" runat="server">
125 </asp:DropDownList>
126 </td>
127 </tr>
128 <tr>
129 <td align="right">
130 Image 1:</td>
131 <td align="left">
132
133 <asp:FileUpload ID="FileUpload1" runat="server" />
134 </td>
135 </tr>
136 <tr>
137 <td align="right">
138 Image 2:</td>
139 <td align="left">
140 <asp:FileUpload ID="FileUpload2" runat="server" />
141 </td>
142 </tr>
143 <tr>
144 <td align="right">
145 Image 3:</td>
146 <td align="left">
147 <asp:FileUpload ID="FileUpload3" runat="server" />
148 </td>
149 </tr>
150 <tr>
151 <td>
152 &nbsp;</td>
153 <td>
154 &nbsp;</td>
155 </tr>
156 <tr>
157 <td align="right">
158 <asp:Button ID="Button1" runat="server" Text="Save" />
159 </td>
160 <td>
161 &nbsp;</td>
162 </tr>
163
164
165 </table>
166
167 </div>
168
169
170 <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:treesConnectionString %>"
171 InsertCommand="INSERT INTO SueHorvath(Address, City, State, ZipCode, ListPrice, Taxes, Subdivision, County, SchoolDistrict, Bedrooms, Bathrooms, LivingSpace, Stories, BuildingStyle, YearBuilt, Basement, Heating, Cooling, Image1, Image2, Image3) VALUES (@Address, @City, @State, @ZipCode, @ListPrice, @Taxes, @Subdivision, @County, @SchoolDistrict, @Bedrooms, @Bathrooms, @LivingSpace, @Stories, @BuildingStyle, @YearBuilt, @Basement, @Heating, @Cooling, @Image1, @Image2, @Image3)" >
172 <InsertParameters>
173 <asp:ControlParameter Name="Address" Type="String"
174 ControlID="TbAddress" />
175 <asp:ControlParameter Name="City" Type="String"
176 ControlID="TbCity" />
177 <asp:ControlParameter Name="State" Type="String"
178 ControlID="DdState" />
179 <asp:ControlParameter Name="ZipCode" Type="String"
180 ControlID="TbZipCode" />
181 <asp:ControlParameter Name="ListPrice" Type="String"
182 ControlID="TbListingPrice" />
183 <asp:ControlParameter Name="Taxes" Type="String"
184 ControlID="TbTaxes" />
185 <asp:ControlParameter Name="Subdivision" Type="String"
186 ControlID="TbSubdivision" />
187 <asp:ControlParameter Name="County" Type="String"
188 ControlID="TbCounty" />
189 <asp:ControlParameter Name="SchoolDistrict" Type="String"
190 ControlID="TbSchoolDistrict" />
191 <asp:ControlParameter Name="Bedrooms" Type="String"
192 ControlID="DdBedrooms" />
193 <asp:ControlParameter Name="Bathrooms" Type="String"
194 ControlID="DdBedrooms" />
195 <asp:ControlParameter Name="LivingSpace" Type="String"
196 ControlID="TbLivingSpace" />
197 <asp:ControlParameter Name="Stories" Type="String"
198 ControlID="DdStories" />
199 <asp:ControlParameter Name="BuildingStyle" Type="String"
200 ControlID="TbBuildingStyle" />
201 <asp:ControlParameter Name="YearBuilt" Type="String"
202 ControlID="TbYearBuilt" />
203 <asp:ControlParameter Name="Basement" Type="String"
204 ControlID="DdBasement" />
205 <asp:ControlParameter Name="Heating" Type="String"
206 ControlID="DdHeating" />
207 <asp:ControlParameter Name="Cooling" Type="String"
208 ControlID="DdCooling" />
209
210 <asp:ControlParameter Name="FileUpload1" Type="String"
211 ControlID="FileUpload1" />
212 <asp:ControlParameter Name="FileUpload2" Type="String"
213 ControlID="FileUpload2" />
214 <asp:ControlParameter Name="FileUpload3" Type="String"
215 ControlID="FileUpload3" />
216
217
218 </InsertParameters>
219
220 </asp:SqlDataSource>
  And here is the code behind   1
2 Partial Class mylistings
3 Inherits System.Web.UI.Page
4 Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
5
6 SqlDataSource1.Insert()
7 TbAddress.Text = ""
8 TbCity.Text = ""
9 DdState.Text = ""
10 TbZipCode.Text = ""
11 TbListingPrice.Text = ""
12 TbTaxes.Text = ""
13 TbSubdivision.Text = ""
14 TbCounty.Text = ""
15 TbSchoolDistrict.Text = ""
16 DdBedrooms.Text = ""
17 DdBathrooms.Text = ""
18 TbLivingSpace.Text = ""
19 DdStories.Text = ""
20 TbBuildingStyle.Text = ""
21 TbYearBuilt.Text = ""
22 DdBasement.Text = ""
23 DdHeating.Text = ""
24 DdCooling.Text = ""
25
26
27
28
29 Response.Redirect(Request.Url.ToString(), False) ' will include the querystring
30 End Sub
31 End Class
32
  

View 7 Replies View Related

How To Upload And Retrieve Images From The Database

Mar 26, 2008

i am using sql server,asp.net and C# language.I am able to upload data into the database but couldnt retrieve it from the database.i am using the following code to upload image into the database.kindly help.
 
 SqlConnection connection = null;         try         {             FileUpload img = (FileUpload)imgUpload;             Byte[] imgByte = null;             if (img.HasFile && img.PostedFile != null)             {                 HttpPostedFile File = imgUpload.PostedFile;                 imgByte = new Byte[File.ContentLength];                 File.InputStream.Read(imgByte, 0, File.ContentLength);             }             string conn = connection establishing string;             connection = new SqlConnection(conn);             connection.Open();             string sql = "insert into imagetable values(@enm, @eimg) SELECT @@IDENTITY";             SqlCommand cmd = new SqlCommand(sql, connection);             cmd.Parameters.AddWithValue("@enm", txtEName.Text.Trim());             cmd.Parameters.AddWithValue("@eimg", imgByte);             int id = Convert.ToInt32(cmd.ExecuteScalar());             lblResult.Text = String.Format("Employee ID is {0}", id);         }         catch         {             lblResult.Text = "There was an error";         }        finally        {            connection.Close();        }

View 9 Replies View Related

How To Insert Images Into Sql Server Database

Jul 10, 2001

hi all

just i want to know how to insert image into database. pl help.

thanks

kum

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved