blob

H

Hrvoje Voda

I'm using this code to get a blob from sql database, and put it into
picturebox, but I don't know how to load it into picturebox.

Code:

sqlConnection.Open();

System.Data.SqlClient.SqlCommand LogoBLOBSelect = new
System.Data.SqlClient.SqlCommand();

LogoBLOBSelect.CommandText = "dbo.[LogoBLOBSelect]";

LogoBLOBSelect.CommandType = System.Data.CommandType.StoredProcedure;

LogoBLOBSelect.Connection = sqlConnection;

LogoBLOBSelect.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@RETURN_VALUE",
System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue,
false, ((System.Byte)(0)), ((System.Byte)(0)), "",
System.Data.DataRowVersion.Current, null));

LogoBLOBSelect.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@LogoID",
System.Data.SqlDbType.UniqueIdentifier, 16));

LogoBLOBSelect.Parameters["@LogoID"].Value = LogoID;

SqlDataReader sqlRead = LogoBLOBSelect.ExecuteReader();

if (sqlRead.Read())

{

int s = sqlRead.GetInt32 ( 2 );

Byte[] arBuffer = new Byte;

sqlRead.GetBytes(3, 0, arBuffer, 0, s);

FileStream fs = new FileStream(

sLogoPic, FileMode.OpenOrCreate, FileAccess.Write);

fs.Write(arBuffer, 0, s);

Picture = Image.FromStream(fs); --> this is an image variable that I want to
use to put it into picturebox.

fs.Close();

}

sqlRead.Close();

sqlConnection.Close();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top