473,232 Members | 1,411 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,232 software developers and data experts.

extract blob from database

I would like to be able to extract a BLOB from the database (SqlServer)
and pass it to a browser without writing it to a file. (The BLOB's
are word doc's, MS project doc's, and Excel spreadsheets.

How can I do this?
Nov 18 '05 #1
6 2193
Hi, Selen,

Have a look at this:

[HOW TO: Read and Write BLOB Data by Using ADO.NET Through ASP.NET]
http://support.microsoft.com/default.aspx?kbid=326502

At the end of the article there are links to articles that explain how to
read/write files.

Hope this helps
Martin
"Selen" <sk*****@yahoo.com> wrote in message
news:#j*************@tk2msftngp13.phx.gbl...
I would like to be able to extract a BLOB from the database (SqlServer)
and pass it to a browser without writing it to a file. (The BLOB's
are word doc's, MS project doc's, and Excel spreadsheets.

How can I do this?

Nov 18 '05 #2
To define the default file name the user will see client side :
http://support.microsoft.com/default...en-us%3B260519

Then you can stream the blob (just write to Response instead) :

http://msdn.microsoft.com/library/de...todatabase.asp

Patrice

--

"Selen" <sk*****@yahoo.com> a écrit dans le message de
news:%2***************@tk2msftngp13.phx.gbl...
I would like to be able to extract a BLOB from the database (SqlServer)
and pass it to a browser without writing it to a file. (The BLOB's
are word doc's, MS project doc's, and Excel spreadsheets.

How can I do this?


Nov 18 '05 #3
I write this code but it opens in word my forms view....not mydata..

SqlConnection conn=new SqlConnection ();

conn.ConnectionString
="server=(local)\\sql2000;database=db_Kalite_Data; uid=sa;pwd=antalya";

conn.Open ();

string strSql="select FileLocation from tb_Document where DocId=61";

SqlDataAdapter da=new SqlDataAdapter (strSql,conn);

SqlCommandBuilder cmb=new SqlCommandBuilder (da);

DataSet ds=new DataSet ();

da.Fill (ds,"tb_Document");
Response.Buffer =true;

Response.AddHeader("Content-Disposition", "attachment;filename=blob.doc");

Response.ContentType = "application/msword";

Response.BinaryWrite (ds.Tables[0].Rows[0][0] as byte [] );

"Patrice Scribe" <no****@nowhere.com>, iletide sunu yazdi
news:O8*************@TK2MSFTNGP12.phx.gbl...
To define the default file name the user will see client side :
http://support.microsoft.com/default...en-us%3B260519

Then you can stream the blob (just write to Response instead) :

http://msdn.microsoft.com/library/de...todatabase.asp
Patrice

--

"Selen" <sk*****@yahoo.com> a écrit dans le message de
news:%2***************@tk2msftngp13.phx.gbl...
I would like to be able to extract a BLOB from the database (SqlServer)
and pass it to a browser without writing it to a file. (The BLOB's
are word doc's, MS project doc's, and Excel spreadsheets.

How can I do this?

Nov 18 '05 #4
It looks like you are still sending some HTML code while streaming the word
document.

You must send only the word file to the browser, don't send any HTML code.
Usually a page whose sole purpose is to stream the file content is used
(plus you can reuse this page all over your app) . You'll have also to
suppress the default HTML tags the designer will put in this new page.

--

"Selen" <sk*****@yahoo.com> a écrit dans le message de
news:uJ**************@TK2MSFTNGP09.phx.gbl...
I write this code but it opens in word my forms view....not mydata..

SqlConnection conn=new SqlConnection ();

conn.ConnectionString
="server=(local)\\sql2000;database=db_Kalite_Data; uid=sa;pwd=antalya";

conn.Open ();

string strSql="select FileLocation from tb_Document where DocId=61";

SqlDataAdapter da=new SqlDataAdapter (strSql,conn);

SqlCommandBuilder cmb=new SqlCommandBuilder (da);

DataSet ds=new DataSet ();

da.Fill (ds,"tb_Document");
Response.Buffer =true;

Response.AddHeader("Content-Disposition", "attachment;filename=blob.doc");

Response.ContentType = "application/msword";

Response.BinaryWrite (ds.Tables[0].Rows[0][0] as byte [] );

"Patrice Scribe" <no****@nowhere.com>, iletide sunu yazdi
news:O8*************@TK2MSFTNGP12.phx.gbl...
To define the default file name the user will see client side :
http://support.microsoft.com/default...en-us%3B260519

Then you can stream the blob (just write to Response instead) :

http://msdn.microsoft.com/library/de...todatabase.asp

Patrice

--

"Selen" <sk*****@yahoo.com> a écrit dans le message de
news:%2***************@tk2msftngp13.phx.gbl...
I would like to be able to extract a BLOB from the database (SqlServer) and pass it to a browser without writing it to a file. (The BLOB's
are word doc's, MS project doc's, and Excel spreadsheets.

How can I do this?



Nov 18 '05 #5
I think I dont understand this:(((((
Could you give me an example????
How can I send only word not html...? :(

Thank you for your response...:)
"Patrice Scribe" <no****@nowhere.com>, iletide sunu yazdi
news:us**************@TK2MSFTNGP09.phx.gbl...
It looks like you are still sending some HTML code while streaming the word document.

You must send only the word file to the browser, don't send any HTML code.
Usually a page whose sole purpose is to stream the file content is used
(plus you can reuse this page all over your app) . You'll have also to
suppress the default HTML tags the designer will put in this new page.

--

"Selen" <sk*****@yahoo.com> a écrit dans le message de
news:uJ**************@TK2MSFTNGP09.phx.gbl...
I write this code but it opens in word my forms view....not mydata..

SqlConnection conn=new SqlConnection ();

conn.ConnectionString
="server=(local)\\sql2000;database=db_Kalite_Data; uid=sa;pwd=antalya";

conn.Open ();

string strSql="select FileLocation from tb_Document where DocId=61";

SqlDataAdapter da=new SqlDataAdapter (strSql,conn);

SqlCommandBuilder cmb=new SqlCommandBuilder (da);

DataSet ds=new DataSet ();

da.Fill (ds,"tb_Document");
Response.Buffer =true;

Response.AddHeader("Content-Disposition", "attachment;filename=blob.doc");

Response.ContentType = "application/msword";

Response.BinaryWrite (ds.Tables[0].Rows[0][0] as byte [] );

"Patrice Scribe" <no****@nowhere.com>, iletide sunu yazdi
news:O8*************@TK2MSFTNGP12.phx.gbl...
To define the default file name the user will see client side :
http://support.microsoft.com/default...en-us%3B260519

Then you can stream the blob (just write to Response instead) :

http://msdn.microsoft.com/library/de...todatabase.asp

Patrice

--

"Selen" <sk*****@yahoo.com> a écrit dans le message de
news:%2***************@tk2msftngp13.phx.gbl...
> I would like to be able to extract a BLOB from the database (SqlServer) > and pass it to a browser without writing it to a file. (The BLOB's
> are word doc's, MS project doc's, and Excel spreadsheets.
>
> How can I do this?
>
>


Nov 18 '05 #6
In design mode clear all but the page directive. You'll then have a single
<%@Page... line.

The code behind then just contains some code such as :

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Const MyFile As String="myfile.doc"

Response.AddHeader("content-disposition", "attachment;filename=" & MyFile)

Response.WriteFile("c:\mylocation\" & MyFile)

End Sub

You can start by trying this. You' ll have then to switch to streaming from
a BLOB once the browser mechanism is ok.

You can use this page from whatever location :
<a href="/download.aspx?id=whatever" target="_blank">Donwload now</A>

The id could be used to know what content is to be downloaded. The download
page could also check first if the connected user is allowed to download
this particular resource.

Hope it helps...
--

"Selen" <sk*****@yahoo.com> a écrit dans le message de
news:O3**************@TK2MSFTNGP09.phx.gbl...
I think I dont understand this:(((((
Could you give me an example????
How can I send only word not html...? :(

Thank you for your response...:)
"Patrice Scribe" <no****@nowhere.com>, iletide sunu yazdi
news:us**************@TK2MSFTNGP09.phx.gbl...
It looks like you are still sending some HTML code while streaming the

word
document.

You must send only the word file to the browser, don't send any HTML code.
Usually a page whose sole purpose is to stream the file content is used
(plus you can reuse this page all over your app) . You'll have also to
suppress the default HTML tags the designer will put in this new page.

--

"Selen" <sk*****@yahoo.com> a écrit dans le message de
news:uJ**************@TK2MSFTNGP09.phx.gbl...
I write this code but it opens in word my forms view....not mydata..

SqlConnection conn=new SqlConnection ();

conn.ConnectionString
="server=(local)\\sql2000;database=db_Kalite_Data; uid=sa;pwd=antalya";

conn.Open ();

string strSql="select FileLocation from tb_Document where DocId=61";

SqlDataAdapter da=new SqlDataAdapter (strSql,conn);

SqlCommandBuilder cmb=new SqlCommandBuilder (da);

DataSet ds=new DataSet ();

da.Fill (ds,"tb_Document");
Response.Buffer =true;

Response.AddHeader("Content-Disposition",

"attachment;filename=blob.doc");
Response.ContentType = "application/msword";

Response.BinaryWrite (ds.Tables[0].Rows[0][0] as byte [] );

"Patrice Scribe" <no****@nowhere.com>, iletide sunu yazdi
news:O8*************@TK2MSFTNGP12.phx.gbl...
> To define the default file name the user will see client side :
> http://support.microsoft.com/default...en-us%3B260519
>
> Then you can stream the blob (just write to Response instead) :
>
>

http://msdn.microsoft.com/library/de...todatabase.asp
>
> Patrice
>
> --
>
> "Selen" <sk*****@yahoo.com> a écrit dans le message de
> news:%2***************@tk2msftngp13.phx.gbl...
> > I would like to be able to extract a BLOB from the database

(SqlServer)
> > and pass it to a browser without writing it to a file. (The BLOB's
> > are word doc's, MS project doc's, and Excel spreadsheets.
> >
> > How can I do this?
> >
> >
>



Nov 18 '05 #7

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

Similar topics

7
by: John | last post by:
I have over 5000 thumbnail pictures of size 5kb each. I would like to able to load all 5000 pictures and view 50 per page using mysql_data_seek(). I would like to know what are the advantages and...
5
by: Bob Kaku | last post by:
I've created a MySQL database to store a large amount of text. Since the text data type in MySQL is limited to 255 characters, I added a BLOB column. I created an PHP input screen to enter the...
6
by: Juergen Gerner | last post by:
Hello Python fans, I'm trying and searching for many days for an acceptable solution... without success. I want to store files in a database using BLOB fields. The database table has an ID field...
0
by: REM | last post by:
I have some problems. It's dilemma between BLOB, BFILE and takes care of file on file system. What it's advantage?? I import some PDF document in BLOB filed in my database. It's about 1000...
3
by: hamvil79 | last post by:
I'm implementig a java web application using MySQL as database. The main function of the application is basically to redistribuite documents. Those documents (PDF, DOC with an average size around...
3
by: Selen | last post by:
I would like to be able to extract a BLOB from the database (SqlServer) and pass it to a browser without writing it to a file. (The BLOB's are word doc's, MS project doc's, and Excel spreadsheets....
9
by: Hrvoje Voda | last post by:
I wrote this code to save a blob data into database. What is wrong? public ArrayList SetProfile(byte Profile) { ArrayList arrayProfile = new ArrayList ();
10
by: Peter Stojkovic | last post by:
I want store an integer-array of 1000 Values in a blob in a SQL-database. I will do this every 10 Seconds. How can I do this ???? What datatypes a have to use ??? Thanks
2
by: Vinciz | last post by:
hi guys... im new in java and i would love to learn some of these... basically i got a sample code to retrieve the blob from the mysql. however, i dont really know what to do with these...
4
by: skunapareddy | last post by:
I am needing to read a blob from database and pass it to another java program. I researched internet and found a program that reads a file on the client pc and gives bytes, but when I modified the...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...

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.