?
Solved

Opening an Excel TEMPLATE that is Stored as a BLOB in SQL Server

Posted on 2003-10-21
13
Medium Priority
?
182 Views
Last Modified: 2010-05-01
I have a table that stores EXCEL templates.  :

Here is what I have:

set cn=SERVER.CreateObject("ADODB.CONNECTION")
cn.ConnectionString="Provider=SQLOLEDB.1;Persist Security Info=False;" & _
    "Initial Catalog=dbAS_FAC_CENSUS;Data Source=ASDEV" & _
    ";User Id=" & Request.Form("txtUserID") & _
    ";Password=" & Request.Form("txtPwd")
cn.Open
set rs=server.CreateObject("ADODB.RECORDSET")
set rs.ActiveConnection=cn
rs.Open("SELECT * FROM vwMART_REPORTS WHERE strUserID='" & Request.Form("txtUserID") & "'")

THE rs("Report") field has the actual Template.  How do I open the contents of that field in Excel?
0
Comment
Question by:clangl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 5
13 Comments
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9593181
you have to create a temporary local file and open it.
0
 

Author Comment

by:clangl
ID: 9593965
But how do I get it from the table to a local file?
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9594073
OK. You need to use ADDB.stream object (more on this later)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9594091
0
 
LVL 16

Accepted Solution

by:
Richie_Simonetti earned 1000 total points
ID: 9594101
0
 

Author Comment

by:clangl
ID: 9594180
with the ADo stream method....
What my goal is, is to have them click on this link on a web browser that points to that Field in the table and then have excel open right up......
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9598881
But that's a complete diferent scenario!!!
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9598901
You need to create/extract the file at server side after user does the click and navigate to resulting xls file. It should be opened in web browser window.
0
 

Author Comment

by:clangl
ID: 9608892
This will work but I need to be able to do this with out saving it to a file.  I will post another question.  Thank you for your help.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9609096
Hummm, i think you can't but i maybe wrong.
Thanks for "A" grade.
0
 

Author Comment

by:clangl
ID: 9614325
I ended up not using a stream.
Just in case you ever need something similiar here is what I ended up doing:

<%
Response.buffer = TRUE
'on error resume next
dim strReport
strReport=left(Request.Form.Item,instr(1,Request.Form.Item,"=")-1)
'Response.Write strReport

dim cn, cmd,rs
set cn=SERVER.CreateObject("ADODB.CONNECTION")
set rs=server.CreateObject("ADODB.Recordset")
cn.ConnectionString="Provider=SQLOLEDB.1;Persist Security Info=False;" & _
    "Initial Catalog=dbAS_FAC_CENSUS;Data Source=ASDEV" & _
    ";User Id=" &  Session("User") & _
    ";Password=" & Session("Pwd")
cn.Open
set cmd=server.CreateObject("ADODB.Command")
set cmd.ActiveConnection=cn
cmd.CommandType=4
cmd.CommandText="sp_MART_GetReport"
set rs=cmd.Execute(,strReport)
set fld=rs.Fields(0)
cBytes = fld.ActualSize
Response.Clear
'Response.ContentType = "application/vnd-ms-excel"
      Response.ContentType = rs.Fields(1).Value
      Response.AddHeader "Content-Disposition", "filename=a.xlt;"
      Response.BinaryWrite (fld.GetChunk(cBytes))
rs.Close
set fld=nothing
set rs=nothing
set cmd=nothing
cn.Close
set cn=nothing

%>
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9614344
excellent!!, that's for sure far ago from my knowledge. excellent work again.
(I really think you accepted my comment too soon :)
0
 

Author Comment

by:clangl
ID: 9614401
I ended up using your answer to back in all the Templates to the SQL Database.  
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month14 days, 12 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question