Outputting MSSQL 2000 Image DataType??

  • Thread starter TJ Meadows via .NET 247
  • Start date
T

TJ Meadows via .NET 247

Ok this seemed like a simple task im programming in c# .NET
the problem comes when i try to print a image back out of thedatabase to the browser.

Here is my code:

Response.ContentType = "image/jpeg";
DataSet DS = new DataSet();

// MSSQL Connection
SqlConnection sqlConn = new SqlConnection("SERVER=" +ConfigurationSettings.AppSettings["dbSource"].ToString() +";UID=" +ConfigurationSettings.AppSettings["dbUserName"].ToString() +";PWD=" +ConfigurationSettings.AppSettings["dbPassword"].ToString() +";DATABASE=" +ConfigurationSettings.AppSettings["dbDatabase"].ToString());


// [ProductType] Data Set
SqlDataAdapter sqlDataAdapt = new SqlDataAdapter("SELECT SourceFROM ImageMatrix WHERE GUID = '" + GUID + "'", sqlConn);
sqlDataAdapt.Fill(DS, "Image");
DataTable CurrentTable = DS.Tables[0];

if (CurrentTable.Rows.Count != 0)
{
Response.BinaryWrite((byte[])CurrentTable.Rows[0]["Source"]);
}

Ok yet again the code looks simple enough YET it doesnt work allthat gets printed out to the browser is System.Byte[] its reallyannoying does anyone know why its printing the textSystem.Byte[] vrs the actual image??

Thanks!!
 

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

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top