C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Images »

Saving the image file in SQL server


Posted Date: 07 Jul 2009    Resource Type: Code Snippets    Category: Images
Author: Anil Kumar PandeyMember Level: Diamond    
Rating: 1 out of 5Points: 12



Saving the image in SQL Server
hi,

The following is the sample code to show that how we can save the image in the SQL Server. we have to take the column type as IMAGE, and using the BYTE array we can save the uploaded image.

please check the following code for this.



SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
con.Open();
byte[] ImgBytes = new byte[flurl.PostedFile.InputStream.Length];
flurl.PostedFile.InputStream.Read(ImgBytes, 0, ImgBytes.Length);
string qry = "Insert into Table1(ImageData) values(@ImageData)";
SqlCommand cmd = new SqlCommand(qry, con);
cmd.Parameters.AddWithValue("@ImageData", ImgBytes);
cmd.ExecuteNonQuery();
con.Close();



Happy Coading!!!!!!

Thanks
Anil Kumar Pandey
System Architect
Green Point Technology (India) Ltd.
Mumbai, Maharshtra
INDIA



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Saving image in Sql server  .  Image upload  .  Image Processing  .  Anil Pandey  .  Anil Kumar Pandey  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Creating Thumbnail Images in C#
Previous Resource: Retrieving Image from SQL Server
Return to Discussion Resource Index
Post New Resource
Category: Images


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use