The text of this article is not in this database — only its details are. Read it on the old site: Save an Image to SQL Server
8 Comments
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment.
The text of this article is not in this database — only its details are. Read it on the old site: Save an Image to SQL Server
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment.
Awadhendra TiwariPosted Aug 22, 2011, 10:57 AM
Save Image in SQL Server: http://www.mindstick.com/Articles/982a3316-c8a6-4b81-82ef-c064f27118d9/?Store%20image%20in%20SQL%20Server%20database Save Image in SQL Server by using C# http://www.mindstick.com/Blog/184/Save%20image%20in%20SqlServer%20using%20C
Uyya AzzaPosted Dec 26, 2010, 9:39 PM
Thanks yooo 4 article... :)
Golam TaherPosted Aug 7, 2010, 1:11 PM
Very Useful
manikantan pPosted Feb 19, 2010, 1:13 AM
Prerequisites Knowledge in Using MS SQL Server Stored Procedure Knowledge in C#.NET Windows Application Knowledge in ADO.NET Introduction How to Store or Save Image in MS SQL Server table This article talks about using Images data type in MS SQL Server and also provides sample code to store images in MS SQL Server database. To store an image in to sql server, you need to read image file into a byte array. Once you have image data in byte array, you can easity store this image data in sql server using sql parameters. Following code explains you how to convert the image data into byte array using byte img = Convert.Tobyte(img); . Using the code A brief description of how to use the article or code. The class names, the methods and properties, any tricks or tips. Blocks of code should be set as style "Formatted" like this: Collapse using System.Data; using System.Data.Sql using System.Data.SqlClient; using System.Web; using System.Web.Services; public class FileUploader: System.Web.Services.WebService { ""MsoNormal""> SqlConnection myConnection = new SqlConnection("Data Source=server name ;Initial Catalog=database name; User ID=username; Password='password';"); SqlCommand myCommand = new SqlCommand(); string queryString = ""; public string UploadFile(byte[] f, string fileName) { // the byte array argument contains the content of the file // the string argument contains the name and extension // of the file passed in the byte array string nm = data[0]; string sn =data[1]; string bn =data[2]; string st = data[3]; byte img = Convert.Tobyte(img); myConnection.Open(); queryString = "INSERT INTO tablename(Name,SchemeName,BeneficiarName,Status,Photo)" + "VALUES('" + nm + "','" + sn + "','"+ bn +"','" + st + "',@img,'")"; myCommand.Parameters.AddWithValue(" @img",f); myCommand.Connection = myConnection; myCommand.CommandType = CommandType.Text; myCommand.CommandText = queryString; int res = myCommand.ExecuteNonQuery(); myConnection.Close(); if (res > 0) { strres = "File Uploaded successfully"; } else { strres = "File not uploaded"; } return strres; } Requirements Visual Studio.Net 2005 .Net Framework 2.0 MS SQL Server 2000 database or MS SQL Server 2005 database.
Aguirre ArellanoPosted Jul 16, 2009, 11:54 PM
Nice one really help me a lots! God bless!
sam johnPosted Jun 28, 2009, 9:00 AM
Nice Code mate ... Well done
adas efrfPosted Apr 4, 2009, 9:22 PM
no entendi j