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());
}
}
}
}