473,401 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

NorthWind Database, can't view images

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

Jun 1 '08 #1
2 5474
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" <j.***********@gmail.comschreef in bericht
news:93**********************************@34g2000h sh.googlegroups.com...
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());
}
}
}
}
Jun 1 '08 #2
JP
On 1 jun, 02:49, "Cor Ligthert[MVP]" <notmyfirstn...@planet.nlwrote:
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" <j.pablobla...@gmail.comschreef in berichtnews:93**********************************@3 4g2000hsh.googlegroups.com...
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
Jun 1 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: RibGnaw | last post by:
Long, long ago when Access 97 first hit the streets a sample database called Northwind was shipped with it. At that time a number of articles had been posted on the correct procedure to remove all...
8
by: xtra | last post by:
Hi Folk I looked at the Northwind Sample Database for the first time recently and I was just wondering why they made it so ugly. If northwind is supposed to be inspiring to young and hopeful...
12
by: Wadim Grasza | last post by:
I want to store and display (on a form or a report) multiple pictures per record in an access database. The pictures are not stored within the database. They are stored as files and the database...
2
by: dennist685 | last post by:
Can't open Northwind I remembered doing walkthrough using Northwind. However it wasn't an http project but a file project using the development server. Northwind allowed me to add, edit and...
9
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web...
7
by: eholz1 | last post by:
Hello Group, Perhaps you can help me. I have a mysql db, that holds images. Images are encoded using base64_decode/encode, etc. Image data seems fine. I have a view.php page that is supposed...
4
by: aomhussien | last post by:
how can i delete all data from the northwind database sample that comes with msaccess? i want to adapt it to my own use!!!!
2
by: JP | last post by:
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...
0
by: amazingpeople | last post by:
I have a winform with one pictureBOx and one datanavigator control. I want to bind them to Northwind Employees table(Photo column) with the following code. I can see the images and can navigate...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.