Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 SQL Query Binary return using browser

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-02-10 : 19:31:25
William writes "ok, I've been tasked to basically query a database, get the rows, and what not. Done. Now, they want me to, on one row of this table, have the row return in readable text form; the binary field in viewable text.

ARGH!!!!"

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2002-02-10 : 20:32:12
What is stored in the binary field ?

Could you just convert it to a varchar or something ?

I.E.

Select Cast(mybinaryfield as VarChar(1000))
FROM mytable



Damian
Go to Top of Page

gerbick
Starting Member

11 Posts

Posted - 2002-02-10 : 23:36:06
it's a multi-part MIME file. Base 64 encoded.

However, before it's inserted, if I were to open the file, I can see the binary encoding/description, and the MIME wrapper info in plain English. of course, the file is binary encoded.

and I forgot, this is from a browser. so, ASP :(

___________________
gerbick
Go to Top of Page

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2002-02-10 : 23:42:04
Is it an image file you want to display ?

Damian
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-02-11 : 07:36:22
If you are delivering this through an ASP page, you'll have to play some tricks with the response.ContentType in order for this to look correct. It's really an ASP problem; SQL Server doesn't know from base64 encoding. And I assume the MIME types could be image/jpeg, image/gif, etc., basically any type. This is gonna hurt, because you'll have to extract the MIME type from the data and set response.ContentType to match it, then pour the remaining contents into the page. You'll also need to start a brand new page for it (can't have 2 different content types in the same ASP page).

Go to Top of Page

gerbick
Starting Member

11 Posts

Posted - 2002-02-11 : 12:09:05
if it were just an image file, I found some code - I believe - on this site that remedies the issue.

You're right. This issue is a bit trickier than it sounds, and it's mainly an ASP issue. :-/

I just want to take the binary stream, convert it to text, and then read what's there... especially since I'm able to read it before I insert into the database.

___________________
gerbick
Go to Top of Page

gerbick
Starting Member

11 Posts

Posted - 2002-02-12 : 11:15:05
I think I've been going about this the wrong way. I need to look at simply extracting BLOB information.

___________________
gerbick
Go to Top of Page
   

- Advertisement -