469,076 Members | 1,342 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,076 developers. It's quick & easy.

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 2052
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by John | last post: by
5 posts views Thread by Bob Kaku | last post: by
6 posts views Thread by Juergen Gerner | last post: by
3 posts views Thread by hamvil79 | last post: by
3 posts views Thread by Selen | last post: by
9 posts views Thread by Hrvoje Voda | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.