Hi:
I'm working on a project using ASP and SQL Server 2000.
I have a SQL Server 2000 database that contains a table called 'Supplier_Docs' that contains a field called 'doc_weblink' (varchar data type).
The 'doc_weblink' field holds the names of PDF files (e.g. Budget.pdf)
Here is some code that I use in a tree view in my application using both ASP and Javascript.
--------- Beginning of Code for tree view -------------
...
<%
dim tree
set tree = new treelistcontrol
'specify our default settings for the tree
tree.allowrowselect = false
tree.showborder = false
tree.pathtoicons = "treelistcontrol/"
tree.showdividers = false
'define the columns for the tree
tree.addcolumn "Agreement ID Number", "", ""
tree.addcolumn "WebLink", "200", ""
tree.addcolumn "ID #", "100", ""
tree.addcolumn "SRAN", "80", ""
tree.addcolumn "JULIAN", "100", ""
tree.addcolumn "Supplier", "200", ""
tree.addcolumn "Receiver", "200", ""
tree.addcolumn "Version", "100", ""
tree.addcolumn "Date", "100", ""
dim id, parentid, theWeblink, theidNum, theSRAN, theJULIAN, theSupplier, theReceiver, theVersion, theDate
parentid = "0"
theWeblink = "Web Link Text"
theidNum = "100"
'add the node
counter=1
set rs =server.createobject("ADODB.Recordset")
rs.ActiveConnection = MM_sar_STRING
parentid="0"
do while not rsAgreements_Supplier.eof
tree.addnode cstr(counter), "0", "treelistcontrol/icon_folder.gif", false, array(cstr(rsAgreements_Supplier("ID #")),"","","","","","","","")
rs.source= "select * from supplier_docs where ID='" & rsAgreements_Supplier("ID #") & "'"
rs.open()
ccounter=counter
do while not rs.eof
counter=counter+1
weblink=trim(rs("doc_weblink") & "")
if weblink<>"" then
weblink="<a href='\\Bolfmws01\ISSA\ISSA Scanned\" & weblink & "' target='_blank'>" & weblink & "</a>"
end if
tree.addnode cstr(counter), cstr(ccounter), "treelistcontrol/icon_folder.gif", false, array(cstr(rs("JULIAN")), weblink,cstr(rs("ID") & ""),cstr(rs("SRAN") & ""),cstr(rs("JULIAN") & ""),cstr(rs("Supplier") & ""),cstr(rs("Receiver") & ""),cstr(rs("Doc_Version") & ""),cstr(rs("Doc_Date") & "")) 'cstr(rs("JULIAN") &, rs("ID"), rs("SRAN"), rs("JULIAN"), rs("Supplier"), rs("Receiver"), rs("Doc_Version"), rs("Doc_Date"))
rs.movenext
loop
rs.close
rsAgreements_Supplier.movenext
counter=counter+1
loop
tree.revealnode counter-1
response.write tree.value
%>
--------- End of Code for tree view -------------
Notice that in my code above, I use a variable called 'weblink'. This variable stores the values from the 'doc_weblink' field in my 'Supplier_Docs' table.
In this line of code taken from above, I loop through the weblink variable in my tree view:
weblink=trim(rs("doc_weblink") & "")
if weblink<>"" then
weblink="<a href='\\Bolfmws01\ISSA\ISSA Scanned\" & weblink & "' target='_blank'>" & weblink & "</a>"
All of this code works just great in my tree view.
My issue is that I need to integrate this code with some code that I use to send binary data (those PDF files mentioned above) via ASP from a remote server to the browser. Here is the code that I used to do this and it works just fine:
-------------- Beginning of code for Binary Data Read -----
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Function ReadBinaryFile(FileName)
Const adTypeBinary = 1
'Create Stream object
Dim BinaryStream
Set BinaryStream = CreateObject("ADODB.Stream")
'Specify stream type - we want To get binary data.
BinaryStream.Type = adTypeBinary
'Open the stream
BinaryStream.Open
'Load the file data from disk To stream object
BinaryStream.LoadFromFile FileName
'Open the stream And get binary data from the object
ReadBinaryFile = BinaryStream.Read
End Function
%>
<%
Response.Buffer = True
Response.Clear()
Response.AddHeader "content-disposition", "inline; filename=" & FileName
Response.ContentType = "application/pdf"
vStream = ReadBinaryFile("F:\Projects\SARTS\Budget.pdf")
Response.BinaryWrite(vStream)
Response.End()
%>
-------------- End of code for Binary Data Read --------
How do I integrate the the two pieces of code together?
Do I say something like?
vStream = ReadBinaryFile(weblink)
Response.BinaryWrite(vStream) ....
Keep in mind that I still need for the 'weblink' to be a hyperlink:
...
weblink ="<a href='\\Bolfmws01\ISSA\ISSA Scanned\" & weblink & "' target='_blank'>" & weblink & "</a>"....
So, how do I integrate the ReadBinaryFile function and Response object code into this hyperlink code?
Any help would be greatly appreciated. I need help to get started on how to integrate the code.
Thanks,
Cheryl3D
I'm working on a project using ASP and SQL Server 2000.
I have a SQL Server 2000 database that contains a table called 'Supplier_Docs' that contains a field called 'doc_weblink' (varchar data type).
The 'doc_weblink' field holds the names of PDF files (e.g. Budget.pdf)
Here is some code that I use in a tree view in my application using both ASP and Javascript.
--------- Beginning of Code for tree view -------------
...
<%
dim tree
set tree = new treelistcontrol
'specify our default settings for the tree
tree.allowrowselect = false
tree.showborder = false
tree.pathtoicons = "treelistcontrol/"
tree.showdividers = false
'define the columns for the tree
tree.addcolumn "Agreement ID Number", "", ""
tree.addcolumn "WebLink", "200", ""
tree.addcolumn "ID #", "100", ""
tree.addcolumn "SRAN", "80", ""
tree.addcolumn "JULIAN", "100", ""
tree.addcolumn "Supplier", "200", ""
tree.addcolumn "Receiver", "200", ""
tree.addcolumn "Version", "100", ""
tree.addcolumn "Date", "100", ""
dim id, parentid, theWeblink, theidNum, theSRAN, theJULIAN, theSupplier, theReceiver, theVersion, theDate
parentid = "0"
theWeblink = "Web Link Text"
theidNum = "100"
'add the node
counter=1
set rs =server.createobject("ADODB.Recordset")
rs.ActiveConnection = MM_sar_STRING
parentid="0"
do while not rsAgreements_Supplier.eof
tree.addnode cstr(counter), "0", "treelistcontrol/icon_folder.gif", false, array(cstr(rsAgreements_Supplier("ID #")),"","","","","","","","")
rs.source= "select * from supplier_docs where ID='" & rsAgreements_Supplier("ID #") & "'"
rs.open()
ccounter=counter
do while not rs.eof
counter=counter+1
weblink=trim(rs("doc_weblink") & "")
if weblink<>"" then
weblink="<a href='\\Bolfmws01\ISSA\ISSA Scanned\" & weblink & "' target='_blank'>" & weblink & "</a>"
end if
tree.addnode cstr(counter), cstr(ccounter), "treelistcontrol/icon_folder.gif", false, array(cstr(rs("JULIAN")), weblink,cstr(rs("ID") & ""),cstr(rs("SRAN") & ""),cstr(rs("JULIAN") & ""),cstr(rs("Supplier") & ""),cstr(rs("Receiver") & ""),cstr(rs("Doc_Version") & ""),cstr(rs("Doc_Date") & "")) 'cstr(rs("JULIAN") &, rs("ID"), rs("SRAN"), rs("JULIAN"), rs("Supplier"), rs("Receiver"), rs("Doc_Version"), rs("Doc_Date"))
rs.movenext
loop
rs.close
rsAgreements_Supplier.movenext
counter=counter+1
loop
tree.revealnode counter-1
response.write tree.value
%>
--------- End of Code for tree view -------------
Notice that in my code above, I use a variable called 'weblink'. This variable stores the values from the 'doc_weblink' field in my 'Supplier_Docs' table.
In this line of code taken from above, I loop through the weblink variable in my tree view:
weblink=trim(rs("doc_weblink") & "")
if weblink<>"" then
weblink="<a href='\\Bolfmws01\ISSA\ISSA Scanned\" & weblink & "' target='_blank'>" & weblink & "</a>"
All of this code works just great in my tree view.
My issue is that I need to integrate this code with some code that I use to send binary data (those PDF files mentioned above) via ASP from a remote server to the browser. Here is the code that I used to do this and it works just fine:
-------------- Beginning of code for Binary Data Read -----
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Function ReadBinaryFile(FileName)
Const adTypeBinary = 1
'Create Stream object
Dim BinaryStream
Set BinaryStream = CreateObject("ADODB.Stream")
'Specify stream type - we want To get binary data.
BinaryStream.Type = adTypeBinary
'Open the stream
BinaryStream.Open
'Load the file data from disk To stream object
BinaryStream.LoadFromFile FileName
'Open the stream And get binary data from the object
ReadBinaryFile = BinaryStream.Read
End Function
%>
<%
Response.Buffer = True
Response.Clear()
Response.AddHeader "content-disposition", "inline; filename=" & FileName
Response.ContentType = "application/pdf"
vStream = ReadBinaryFile("F:\Projects\SARTS\Budget.pdf")
Response.BinaryWrite(vStream)
Response.End()
%>
-------------- End of code for Binary Data Read --------
How do I integrate the the two pieces of code together?
Do I say something like?
vStream = ReadBinaryFile(weblink)
Response.BinaryWrite(vStream) ....
Keep in mind that I still need for the 'weblink' to be a hyperlink:
...
weblink ="<a href='\\Bolfmws01\ISSA\ISSA Scanned\" & weblink & "' target='_blank'>" & weblink & "</a>"....
So, how do I integrate the ReadBinaryFile function and Response object code into this hyperlink code?
Any help would be greatly appreciated. I need help to get started on how to integrate the code.
Thanks,
Cheryl3D