NorthWind Database, can't view images

  • Thread starter Thread starter JP
  • Start date Start date
J

JP

In the table Employees of NorthWind database there is a column Photo
(data type: image). I want to convert the first row image into a jpg
file, but I can't open the file because is not a valid image. What I
am doing wrong?

this is my code...

using System;
using System.Data.SqlClient;
using System.IO;

namespace nwTestCS
{
class Program
{
static void Main(string[] args)
{
using (SqlConnection connection = new
SqlConnection(Properties.Settings.Default.dbStr)) {
connection.Open();
SqlCommand command = new SqlCommand("select photo from
Employees", connection);
File.WriteAllBytes(@"C:\photo.jpg",(byte[])
command.ExecuteScalar());
}
}
}
}
 
JP,

In the Northwind datatabase are Ole bytes array included.
To get the images you need an offset of 78 bytes.

Whatever.Write(ByteArray, 78, ByteArra.Length - 78)

Cor
 
JP,

In the Northwind datatabase are Ole bytes array included.
To get the images you need an offset of 78 bytes.

Whatever.Write(ByteArray, 78, ByteArra.Length - 78)

Cor

JP said:
In the table Employees of NorthWind database there is a column Photo
(data type: image). I want to convert the first row image into a jpg
file, but I can't open the file because is not a valid image. What I
am doing wrong?
this is my code...
using System;
using System.Data.SqlClient;
using System.IO;
namespace nwTestCS
{
   class Program
   {
       static void Main(string[] args)
       {
           using (SqlConnection connection = new
SqlConnection(Properties.Settings.Default.dbStr)) {
               connection.Open();
               SqlCommand command = new SqlCommand("select photo from
Employees", connection);
               File.WriteAllBytes(@"C:\photo.jpg",(byte[])
command.ExecuteScalar());
           }
       }
   }
}

thanks! it worked
 
Back
Top