how to convert image into binary formate and d\saver in database

Posted by Shanky11 under ASP.NET on 10/3/2012 | Points: 10 | Views : 8969 | Status : [Member] | Replies : 5
how to convert image into binary formate and save in database and retrieve it in mysql using asp.net




Responses

Posted by: Vikash on: 10/3/2012 [Member] Starter | Points: 25

Up
0
Down
Plz check following links

http://www.eggheadcafe.com/community/asp-net/17/10413763/how-to-insert-image-in-mysql-database-not-sql-srver.aspx
http://www.eggheadcafe.com/community/asp-net/17/10265831/how-to-store-byte-in-a-blob-column-of-mysql-database-using-odbc-.aspx
http://guruparan.blog.com/2011/06/15/saving-and-retriving-images-from-mysql-databases-using-c-part2/

Plz mark as answer if it helps you......

Regards,
Vikash Pathak

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Dharanidhar on: 10/3/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
see this link..It is helpful for you

http://www.dotnetfunda.com/articles/article1084-saving-images-into-the-database-in-aspnet-and-displaying-to-the-gridview-.aspx

@Dharan23
DotNet Learner

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Solijoseph on: 10/4/2012 [Member] Starter | Points: 25

Up
0
Down
public void InsertImage(string photoFilePath,string connectionString)
{
byte[] photo = LoadImage(photoFilePath);
using (SqlConnection connection = new SqlConnection(connectionString))
{
SqlCommand command = new SqlCommand( "INSERT INTO tblPhotos(Photo) " + "Values(@Photo)", connection);
command.Parameters.Add("@Photo", SqlDbType.Image, photo.Length).Value = photo;
connection.Open();
command.ExecuteNonQuery();
}
}
public static byte[] LoadImage(string filePath)
{
FileStream stream = new FileStream(
filePath, FileMode.Open, FileAccess.Read);
BinaryReader reader = new BinaryReader(stream);
byte[] photo = reader.ReadBytes((int)stream.Length);
reader.Close();
stream.Close();
return photo;
}

Thanks & Regards
Solimon Joseph

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vforvijay on: 10/4/2012 [Member] Starter | Points: 25

Up
0
Down
Hi..
Refer the below link to upload image into database..
http://www.dotnetcode.in/2011/02/upload-image-or-file-into-database-in.html


Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Thackeray on: 1/6/2014 [Member] Starter | Points: 25

Up
0
Down
Convert image to byte array by using the simplest online free sample method and prorgamming code within vb.net framework. Check the online guide on this topic.

http://www.rasteredge.com/how-to/vb-net-imaging/convert-image-to-byte/

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response