Click here to Skip to main content
15,920,602 members
Home / Discussions / C#
   

C#

 
GeneralRe: Multy form question Pin
Jasper4C#28-Sep-03 5:13
Jasper4C#28-Sep-03 5:13 
GeneralRe: Multy form question Pin
I G 19828-Sep-03 19:57
I G 19828-Sep-03 19:57 
GeneralRe: Multy form question Pin
Jasper4C#29-Sep-03 9:31
Jasper4C#29-Sep-03 9:31 
GeneralRemoting and Interfaces Pin
jerrycainjr26-Sep-03 22:11
jerrycainjr26-Sep-03 22:11 
QuestionMDIchild layout? Pin
peenu26-Sep-03 19:01
peenu26-Sep-03 19:01 
GeneralRetrieving Image from SQLServer database Pin
Meysam Mahfouzi26-Sep-03 17:58
Meysam Mahfouzi26-Sep-03 17:58 
GeneralRe: Retrieving Image from SQLServer database Pin
peenu26-Sep-03 19:02
peenu26-Sep-03 19:02 
GeneralRe: Retrieving Image from SQLServer database Pin
Arjan Einbu27-Sep-03 1:23
Arjan Einbu27-Sep-03 1:23 
Use SqlCommand's ExecuteScalar method to retrieve the blob as a byte array, and load it with the Image.FromStream(...) static method using a MemoryStream object.

Sounds easy, eh?

Well, here's a code sample. GetImage() returns an Image object as you requested.

public Image GetImage()
{
	return Image.FromStream(new MemoryStream(LoadImageBLOB(mImagePK)));
}

private byte[] LoadImageBLOB(int imagePK)
{
	string sql = "SET TEXTSIZE 1000000\n" +
		"SELECT the_blob_column FROM the_table " +
		"WHERE the_where_clause\n" +
		"SET TEXTSIZE 0";

	SqlConnection cn = new SqlConnection("the_connection_string");
	SqlCommand cmd = new SqlCommand(sql, cn);

	cn.Open();
	byte[] blob = (byte[])pq.ExecuteScalar();
	cn.Close();

	return blob;
}

GeneralRe: Retrieving Image from SQLServer database Pin
Meysam Mahfouzi27-Sep-03 18:03
Meysam Mahfouzi27-Sep-03 18:03 
Generala Regular Expression question Pin
Meysam Mahfouzi26-Sep-03 17:51
Meysam Mahfouzi26-Sep-03 17:51 
GeneralRe: a Regular Expression question Pin
Blake Coverett27-Sep-03 2:29
Blake Coverett27-Sep-03 2:29 
GeneralRe: a Regular Expression question Pin
Meysam Mahfouzi27-Sep-03 17:58
Meysam Mahfouzi27-Sep-03 17:58 
GeneralRe: a Regular Expression question Pin
27-Sep-03 19:15
suss27-Sep-03 19:15 
GeneralRe: a Regular Expression question Pin
Meysam Mahfouzi28-Sep-03 1:59
Meysam Mahfouzi28-Sep-03 1:59 
GeneralProcesses and RedirectStandardOutput/Error Pin
Wjousts26-Sep-03 10:51
Wjousts26-Sep-03 10:51 
Questionhow to get the wwwroot's full path Pin
aw1ay26-Sep-03 10:33
aw1ay26-Sep-03 10:33 
Generalstrange unwanted strips in PictureBox Pin
israeli26-Sep-03 10:01
israeli26-Sep-03 10:01 
Generalopen directory and list files Pin
nisrinee5126-Sep-03 9:37
nisrinee5126-Sep-03 9:37 
GeneralRe: open directory and list files Pin
Saikat Sen27-Sep-03 12:26
Saikat Sen27-Sep-03 12:26 
GeneralRe: open directory and list files Pin
Anonymous27-Sep-03 12:32
Anonymous27-Sep-03 12:32 
GeneralRe: open directory and list files Pin
Wjousts27-Sep-03 13:29
Wjousts27-Sep-03 13:29 
QuestionHow to draw to a image ? Pin
Chris Richner26-Sep-03 8:18
Chris Richner26-Sep-03 8:18 
GeneralConcurrency options: Optimistic/Pessimistic/Last-Win Pin
devvvy26-Sep-03 7:59
devvvy26-Sep-03 7:59 
GeneralRe: Concurrency options: Optimistic/Pessimistic/Last-Win Pin
Marc Clifton27-Sep-03 3:39
mvaMarc Clifton27-Sep-03 3:39 
GeneralRe: Concurrency options: Optimistic/Pessimistic/Last-Win Pin
Saikat Sen27-Sep-03 12:28
Saikat Sen27-Sep-03 12:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.