473,583 Members | 3,114 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reading Image Data from SQL Server To a Text File

Hello All:

I have a field in the database that is an Image. I have no idea how the
data is stored in here (Image, compressed, encrypted, plain text, etc). I am
trying to write the contents to a text file, image file, etc so I can see if
the data is stored in a way we can understand (we have been tasked to write
an app and the app needs to read this field, but we don't know what it really
contains).

How would I go about reading the data from this field and saving the
contents to a text field, as well as an image? I know conceptually how to do
it, but having issues with the syntax and actual code that is needed.

Thanks
Andy
Nov 16 '05 #1
4 7607
Andy,

If the image is compressed or encrypted, I don't know that looking at
the byte stream is going to do you much good.

Why not just save the contents to a file, and change the extension on
the file, see if anything works opening it?

Also, how is it that you can't know the storage format? Do you have
another system that accesses this DB? If so, do you have the code for that
system?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Andy" <An**@discussio ns.microsoft.co m> wrote in message
news:5E******** *************** ***********@mic rosoft.com...
Hello All:

I have a field in the database that is an Image. I have no idea how the
data is stored in here (Image, compressed, encrypted, plain text, etc). I
am
trying to write the contents to a text file, image file, etc so I can see
if
the data is stored in a way we can understand (we have been tasked to
write
an app and the app needs to read this field, but we don't know what it
really
contains).

How would I go about reading the data from this field and saving the
contents to a text field, as well as an image? I know conceptually how to
do
it, but having issues with the syntax and actual code that is needed.

Thanks
Andy

Nov 16 '05 #2
Nicholas:

Thank you for the response.

We are not sure if the image is compressed or encrypted. All that we know
at this time is the data is stored as an Image in the database. We have a
program that uses this data and displays the information. However: this is
a third party windows tool that we want to re-write portions (for reporting
purposes) for the web. So we are not sure how this software uses that image
data. As a result: we are not sure if the data is stored encrypted,
compressed, hashed or as plain text.

I am not really sure how to save this information to a text file, that is
the issue I am having at the moment. I can't find examples on how to do this
with values from a database.

Thanks
Andy

"Nicholas Paldino [.NET/C# MVP]" wrote:
Andy,

If the image is compressed or encrypted, I don't know that looking at
the byte stream is going to do you much good.

Why not just save the contents to a file, and change the extension on
the file, see if anything works opening it?

Also, how is it that you can't know the storage format? Do you have
another system that accesses this DB? If so, do you have the code for that
system?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Andy" <An**@discussio ns.microsoft.co m> wrote in message
news:5E******** *************** ***********@mic rosoft.com...
Hello All:

I have a field in the database that is an Image. I have no idea how the
data is stored in here (Image, compressed, encrypted, plain text, etc). I
am
trying to write the contents to a text file, image file, etc so I can see
if
the data is stored in a way we can understand (we have been tasked to
write
an app and the app needs to read this field, but we don't know what it
really
contains).

How would I go about reading the data from this field and saving the
contents to a text field, as well as an image? I know conceptually how to
do
it, but having issues with the syntax and actual code that is needed.

Thanks
Andy


Nov 16 '05 #3
Andy,

If it is a byte array (which it would appear that it is), then just open
up a FileStream and then write the file out somewhere. You can change the
extension in explorer and see if any of the programs registered for those
extensions will open it up (like zip programs, image viewers, etc, etc).

If it is encrypted, then you are going to have a problem, since you
probably don't have access to the keys required for decryption.

Given the myriad number of possibilities, it is probably within your
best interests to contact the vendor and ask what the format is, try and get
it from them.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Andy" <An**@discussio ns.microsoft.co m> wrote in message
news:08******** *************** ***********@mic rosoft.com...
Nicholas:

Thank you for the response.

We are not sure if the image is compressed or encrypted. All that we know
at this time is the data is stored as an Image in the database. We have a
program that uses this data and displays the information. However: this
is
a third party windows tool that we want to re-write portions (for
reporting
purposes) for the web. So we are not sure how this software uses that
image
data. As a result: we are not sure if the data is stored encrypted,
compressed, hashed or as plain text.

I am not really sure how to save this information to a text file, that is
the issue I am having at the moment. I can't find examples on how to do
this
with values from a database.

Thanks
Andy

"Nicholas Paldino [.NET/C# MVP]" wrote:
Andy,

If the image is compressed or encrypted, I don't know that looking at
the byte stream is going to do you much good.

Why not just save the contents to a file, and change the extension on
the file, see if anything works opening it?

Also, how is it that you can't know the storage format? Do you have
another system that accesses this DB? If so, do you have the code for
that
system?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Andy" <An**@discussio ns.microsoft.co m> wrote in message
news:5E******** *************** ***********@mic rosoft.com...
> Hello All:
>
> I have a field in the database that is an Image. I have no idea how
> the
> data is stored in here (Image, compressed, encrypted, plain text, etc).
> I
> am
> trying to write the contents to a text file, image file, etc so I can
> see
> if
> the data is stored in a way we can understand (we have been tasked to
> write
> an app and the app needs to read this field, but we don't know what it
> really
> contains).
>
> How would I go about reading the data from this field and saving the
> contents to a text field, as well as an image? I know conceptually how
> to
> do
> it, but having issues with the syntax and actual code that is needed.
>
> Thanks
> Andy


Nov 16 '05 #4
Nicholas:

Perhaps you might be so kind to show me what I am doing wrong (dr["scan"] is
the Image value from the database).

FileStream fs = new FileStream("C:\ \test.txt", FileMode.Create );
BinaryWriter br = new BinaryWriter(fs );
br.Write(fs.Rea d(dr["scan"]));
br.Flush();
br.Close();
fs.Flush();
fs.Close();

Thanks
Andy

"Nicholas Paldino [.NET/C# MVP]" wrote:
Andy,

If it is a byte array (which it would appear that it is), then just open
up a FileStream and then write the file out somewhere. You can change the
extension in explorer and see if any of the programs registered for those
extensions will open it up (like zip programs, image viewers, etc, etc).

If it is encrypted, then you are going to have a problem, since you
probably don't have access to the keys required for decryption.

Given the myriad number of possibilities, it is probably within your
best interests to contact the vendor and ask what the format is, try and get
it from them.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Andy" <An**@discussio ns.microsoft.co m> wrote in message
news:08******** *************** ***********@mic rosoft.com...
Nicholas:

Thank you for the response.

We are not sure if the image is compressed or encrypted. All that we know
at this time is the data is stored as an Image in the database. We have a
program that uses this data and displays the information. However: this
is
a third party windows tool that we want to re-write portions (for
reporting
purposes) for the web. So we are not sure how this software uses that
image
data. As a result: we are not sure if the data is stored encrypted,
compressed, hashed or as plain text.

I am not really sure how to save this information to a text file, that is
the issue I am having at the moment. I can't find examples on how to do
this
with values from a database.

Thanks
Andy

"Nicholas Paldino [.NET/C# MVP]" wrote:
Andy,

If the image is compressed or encrypted, I don't know that looking at
the byte stream is going to do you much good.

Why not just save the contents to a file, and change the extension on
the file, see if anything works opening it?

Also, how is it that you can't know the storage format? Do you have
another system that accesses this DB? If so, do you have the code for
that
system?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Andy" <An**@discussio ns.microsoft.co m> wrote in message
news:5E******** *************** ***********@mic rosoft.com...
> Hello All:
>
> I have a field in the database that is an Image. I have no idea how
> the
> data is stored in here (Image, compressed, encrypted, plain text, etc).
> I
> am
> trying to write the contents to a text file, image file, etc so I can
> see
> if
> the data is stored in a way we can understand (we have been tasked to
> write
> an app and the app needs to read this field, but we don't know what it
> really
> contains).
>
> How would I go about reading the data from this field and saving the
> contents to a text field, as well as an image? I know conceptually how
> to
> do
> it, but having issues with the syntax and actual code that is needed.
>
> Thanks
> Andy


Nov 16 '05 #5

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

Similar topics

3
11752
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a table in MySQL with the path & filename to the image. I have successfully uploaded and performed an update query on the database, but the problem...
10
7386
by: John Smith | last post by:
I know that uploading an image to a database has been covered, oh, about 3 trillion times. However, I haven't found anything covering uploading to a MySQL database with .net. Please don't recommend storing the image to the filesystem and only keeping a pointer to that in the table. I want to dump the image to a table. My code dumps the...
0
2167
by: Anonieko Ramos | last post by:
> I have a graphics images that I want to convert to > ASCII art. How do I do it? > Code: - Default.aspx.cs
3
3625
by: dale zhang | last post by:
Hi, I am trying to read an image from MS Access DB based on the following article: http://www.vbdotnetheaven.com/Code/Sept2003/2175.asp The article author is using PictureBox for windows application, while I am doing for web. I can only find Image from web forms control and HTML control. This may be the root cause of my problem. For...
4
3283
by: dale zhang | last post by:
Hi, I am trying to save and read an image from MS Access DB based on the following article: http://www.vbdotnetheaven.com/Code/Sept2003/2175.asp Right now, I saved images without any errors. After reading the ole object from db, I saved it to C: as file1.bmp and displayed on the web. But it can not be displayed. After I manually sent...
1
2497
by: John Thompson | last post by:
We're sooo close. When we load the page to upload the image, all of the prms go through except the binary image data. Using SQL server with the data type set to "image". Please help! Thanks- John
4
3071
by: Kim | last post by:
Random image downloader for specified newsgroup. Hi I'm writing a small script that will download random images from a specified newsgroup. I've imported yenc into the script but I can't open the image or save it. This is my first script so be gentle! Heres the script ####random group downloader#### import nntplib import string, random...
23
5904
by: Peter | last post by:
I have a problem with a page show_image.asp that returns a jpg image under Windows XP Pro SP2. The page sets content type as: Response.ContentType = "image/jpg" While this works perfectly fine on most machines, on some machines I experience this problem: When loading the page a window pops up that asks if I want to open the document...
3
4409
by: premprakashbhati | last post by:
hi, good evening.. i am going to upload an image in a web form .....for that iam using HTML input(file) control and one web control button i.e., Upload_Button() here is the code ...its work fine when iam using a normal web page... but can't in content page.... Code in Master Page <%@ Master Language="C#" AutoEventWireup="true"...
0
7896
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7827
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8184
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8328
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6581
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5701
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3845
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1434
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1158
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.