Passing Recordset from an ASP page to another HTML page ?

O

Oscar

Stefan and Bob thanks for your documented example and especially that you've
got it running now.
However, where is the action that the ASP page calls the other HTML page to
open in the client browser ?

Are there restrictions with respect to the size of the recordset when using
the resonse object?

Oscar
 
M

Mark J. McGinty

Stefan Berglund said:
On Tue, 31 May 2005 10:08:34 -0400, "Bob Barrows [MVP]"


Cool. I burned an hour yesterday trying to make it work to another
page. Yeah, I use this method exclusively in my VB clients when
retrieving web based SQL data.

The problem you will likely run into is that opening a recordset on a URL is
a.) synchronous, and b.) unforgiving. If anything goes wrong, you're
totally in the dark. (Even if you code your XML source to return errors as
XML, what are you going to do about HTTP errors?)

To mitigate these I like to use MSXML.XMLHTTPRequest (or the equivilent,
MSXML2.XMLHTTP, depending on version.) This gives you the ability to
examine whatever the URL returned, XML or otherwise, plus it can be used
asynchronously.

Recordset.Open also accepts an IStream as it's first parameter, and the
DOMDocument (that's retrieved in XMLHTTPRequest.responseXML) exposes an
IStream.

My 2 cents,
Mark
 
B

Bob Barrows [MVP]

Oscar said:
Stefan and Bob thanks for your documented example and especially that
you've got it running now.
However, where is the action that the ASP page calls the other HTML
page to open in the client browser ?

The html page controls the activity. When the .htm page is opened, it sends
a request via the rs.open statement to the asp page, which runs on the
server and returns the requested recordset. Obviously, you would use
querystring variables to pass parameters to the asp page via the url in the
Open statement to control what data is returned. In fact, using this method,
you are restricted to using the querystring, which is another reason I
prefer using the XMLHTTPRequest object, in addition to the reasons mentioned
by Mark.

Another factor to consider is passing the data back to an asp page. Using
the xmlhttprequest object makes it possible to pass the recordset back to a
server-side page.
Are there restrictions with respect to the size of the recordset when
using the resonse object?
None that I know of. When I experimented with passing recordsets to browser
clients, I made sure the recordsets were not very large (a few hundred rows
at the max). Usualy, I was passing around a disconnected recordset
containing a single row, using UpdateBatch to send changes back to the
database after the recordset had been processed by one or more pages.

Unfortunately, that application crashed and burned: it ran well in
development and testing on several machines. However, a week or so after it
went into production, we started getting calls: "createobject failed ..." on
this machine, "ADO error" on that machine ... updating/reinstalling MDAC on
those machines solved most of the problems, but there were a couple machines
which have never been able to run this app - MDAC was completely hosed on
those machines. As a result, I rewrote the app to remove any mention of ADO
in client-side code, and I have never written another app that used
client-side recordsets. Any client-side data processing is done via XML.

Bob Barrows
 
B

Brian Staff

Bob,
Snipping should be done, no matter which style of quoting is being used. I
will concede that lazy bottom-posters who don't adequately snip are just
as bad as top posters who don't snip.

You're right on about snipping and replying to a specific quote. But in
reality, that is not what most people do. If you`re going to reply without
snipping, then it just seems that top posting is better for me as a reader
than bottom posting. I just get annoyed at having to scroll down past stuff
I have already ready to see the reply. I usually make it a policy of mine to
skip over it if I have to scroll...unless I have a specific interest in the
thread.

So, it seems to me the issue not top posting versus bottom posting...but
whether the poster has bothered to snip or not. I'd rather see reminders
about snipping, which can also help reduce noise and bandwidth.

Brian - not really concerned about my sig line<g>
 
O

Oscar

Hi Bob,

I've been able to draft an ASP page which opens a XML doc to retrieve the
recordset. It is able to display the recordset with the response object.

In this page there is an Active-X grid component (VSFlexgrid) which runs at
the client side and needs to be populated with the record data. I am able to
populate the grid with any data, but I can't refer to the recordset object :

fg.additem "Hi there" 'works good
fg.additem <% rs.Fields("naam") %> 'doesn't work, browser reports
Runtime error MS VBScript (0x800A01C2) wrong amount of arguments or illegal
property assignment : 'Fields'

fg=VSflexgrid
rs=Recorsdet Object

So the client is able to see the rs object since it is able to navigate
through the records, but can't display the value of the field. Any
suggestions?




This is the full ASP :

<html>

<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">

<%
Dim rs
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open =Server.Mappath("db_xml.xml")


Do While not rs.EOF 'this works good
response.write (rs.Fields("naam") & " " & (rs.Fields("woonplaats")
& "<br>"))
rs.movenext
Loop

%>


<SCRIPT ID=clientEventHandlersVBS LANGUAGE=vbscript>
<!--
Sub window_onload
dim memo

' initialize grids
With fg
.FontName = "Verdana"
.FontSize = 9
.Editable = 2 ' flexEDKbdMouse
.BackColorFrozen = &H00E0E0E0&
.AllowUserResizing = 1 ' flexResizeColumns
.AllowUserFreezing = 3 ' flexFreezeBoth
.DataMode = 0 ' fgDMBound
.cols=4
.rows=1
end with

<% rs.movefirst
Do While not rs.EOF %>

fg.additem <% rs.Fields("naam") %>

<% rs.movenext %>
<% Loop %>


End Sub



sub fg_entercell()
with fg
if .col=2 then
Lijst_boekingstypen = "|#" & "deb" & ";" & "deb : betaling van debiteur"
& "|#" & "crd" & ";" & "crd : betaling aan crediteur"
Lijst_boekingstypen = Lijst_boekingstypen & "|#" & "std" & ";" & "std :
standaard" & "|#" & "sal" & ";" & "sal : salarisuitbetaling"
.combolist=Lijst_boekingstypen

'msgbox .col

else
.combolist=""
end if
end with


end sub


-->
</SCRIPT>
</head>

<body>

<!-- load licenses from LPK file -->
<object classid = "clsid:5220cb21-c88d-11cf-b347-00aa00a28331">
<param name = "lpkpath" value = "vsf8.lpk">
</object>


<object classid="clsid:c945e31a-102e-4a0d-8854-d599d7aed5fa"
height=200 width=700
id=fg style="left:0px;top:0px">
<PARAM NAME="_cx" VALUE="9313"><PARAM NAME="_cy" VALUE="6773"><PARAM
NAME="Appearance" VALUE="1"><PARAM NAME="BorderStyle" VALUE="1"><PARAM
NAME="Enabled" VALUE="-1"><PARAM NAME="Font" VALUE="Times New Roman"><PARAM
NAME="MousePointer" VALUE="0"><PARAM NAME="BackColor"
VALUE="16777152"><PARAM NAME="ForeColor" VALUE="12582912"><PARAM
NAME="BackColorFixed" VALUE="-2147483633"><PARAM NAME="ForeColorFixed"
VALUE="-2147483630"><PARAM NAME="BackColorSel" VALUE="49344"><PARAM
NAME="ForeColorSel" VALUE="-2147483634"><PARAM NAME="BackColorBkg"
VALUE="-2147483636"><PARAM NAME="BackColorAlternate" VALUE="16777152"><PARAM
NAME="GridColor" VALUE="-2147483633"><PARAM NAME="GridColorFixed"
VALUE="-2147483632"><PARAM NAME="TreeColor" VALUE="-2147483632"><PARAM
NAME="FloodColor" VALUE="192"><PARAM NAME="SheetBorder"
VALUE="-2147483642"><PARAM NAME="FocusRect" VALUE="1"><PARAM
NAME="HighLight" VALUE="1"><PARAM NAME="AllowSelection" VALUE="-1"><PARAM
NAME="AllowBigSelection" VALUE="-1"><PARAM NAME="AllowUserResizing"
VALUE="0"><PARAM NAME="SelectionMode" VALUE="0"><PARAM NAME="GridLines"
VALUE="1"><PARAM NAME="GridLinesFixed" VALUE="2"><PARAM NAME="GridLineWidth"
VALUE="1"><PARAM NAME="Rows" VALUE="50"><PARAM NAME="Cols" VALUE="2"><PARAM
NAME="FixedRows" VALUE="1"><PARAM NAME="FixedCols" VALUE="0"><PARAM
NAME="RowHeightMin" VALUE="0"><PARAM NAME="RowHeightMax" VALUE="0"><PARAM
NAME="ColWidthMin" VALUE="0"><PARAM NAME="ColWidthMax" VALUE="0"><PARAM
NAME="ExtendLastCol" VALUE="0"><PARAM NAME="FormatString"
VALUE="(Format) 10 3300 9 9 0 0 0 1635 9 9 0 0 0 1320 9 9 0 0 0 1320 9 9 0 0 0 1320 9 9 0 0 0 1320 9 9 0 0 0 1320 9 9 0 0 0 1320 9 9 0 0 0 1320 9 9 0 0 0 1320 9 9 0 0 0 (Text) klant woonplaats "><PARAM
NAME="ScrollTrack" VALUE="0"><PARAM NAME="ScrollBars" VALUE="3"><PARAM
NAME="ScrollTips" VALUE="0"><PARAM NAME="MergeCells" VALUE="0"><PARAM
NAME="MergeCompare" VALUE="0"><PARAM NAME="AutoResize" VALUE="-1"><PARAM
NAME="AutoSizeMode" VALUE="0"><PARAM NAME="AutoSearch" VALUE="0"><PARAM
NAME="AutoSearchDelay" VALUE="2"><PARAM NAME="MultiTotals" VALUE="-1"><PARAM
NAME="SubtotalPosition" VALUE="1"><PARAM NAME="OutlineBar" VALUE="0"><PARAM
NAME="OutlineCol" VALUE="0"><PARAM NAME="Ellipsis" VALUE="0"><PARAM
NAME="ExplorerBar" VALUE="0"><PARAM NAME="PicturesOver" VALUE="0"><PARAM
NAME="FillStyle" VALUE="0"><PARAM NAME="RightToLeft" VALUE="0"><PARAM
NAME="PictureType" VALUE="0"><PARAM NAME="TabBehavior" VALUE="0"><PARAM
NAME="OwnerDraw" VALUE="0"><PARAM NAME="Editable" VALUE="0"><PARAM
NAME="ShowComboButton" VALUE="1"><PARAM NAME="WordWrap" VALUE="0"><PARAM
NAME="TextStyle" VALUE="0"><PARAM NAME="TextStyleFixed" VALUE="0"><PARAM
NAME="OleDragMode" VALUE="0"><PARAM NAME="OleDropMode" VALUE="0"><PARAM
NAME="ComboSearch" VALUE="3"><PARAM NAME="AutoSizeMouse" VALUE="-1"><PARAM
NAME="FrozenRows" VALUE="0"><PARAM NAME="FrozenCols" VALUE="0"><PARAM
NAME="AllowUserFreezing" VALUE="0"><PARAM NAME="BackColorFrozen"
VALUE="0"><PARAM NAME="ForeColorFrozen" VALUE="0"><PARAM
NAME="WallPaperAlignment" VALUE="9"><PARAM NAME="AccessibleName"
VALUE=""><PARAM NAME="AccessibleDescription" VALUE=""><PARAM
NAME="AccessibleValue" VALUE=""><PARAM NAME="AccessibleRole" VALUE="24">
</object>
</p>


</body>
</html>
 
B

Bob Barrows [MVP]

Oscar said:
Hi Bob,

I've been able to draft an ASP page which opens a XML doc to retrieve
the recordset. It is able to display the recordset with the response
object.
In this page there is an Active-X grid component (VSFlexgrid) which
runs at the client side and needs to be populated with the record data. I
am
able to populate the grid with any data, but I can't refer to the
recordset
object :

You are no longer asking about ASP. You will need to move this thread to a
client-side scripting newsgroup (one of the .scripting newsgroups, depending
on the language you wish to use in your client-side code will serve your
purpose - hint: using vbscript will prevent the application from working in
non-IE browsers ...). I've never used activex components due to the need for
installing them on the client machines [1] so I am unable to help with this
issue.


[1] which is only going to get harder to do in the future given the focus
being put on browser security.

Bob Barrows
 
O

Oscar

It is a combined ASP/Scripting issue since the recordset is created in ASP
and the visualisation is done both in ASP and Script. My problem is that ASP
alone works well and VBScript alone does also work well, however, ASP is not
able to pass the field value to the VBScript. So it's not only a VBScript
issue, I wish that was the case. I will also post the issue in another
group.

By the way, since the clients PC's are not any PC around the internet but
restricted to some registered users and all of them have already installed
the ActiveX, security is not a main issue.



Bob Barrows said:
Oscar said:
Hi Bob,

I've been able to draft an ASP page which opens a XML doc to retrieve
the recordset. It is able to display the recordset with the response
object.
In this page there is an Active-X grid component (VSFlexgrid) which
runs at the client side and needs to be populated with the record data. I
am
able to populate the grid with any data, but I can't refer to the
recordset
object :

You are no longer asking about ASP. You will need to move this thread to a
client-side scripting newsgroup (one of the .scripting newsgroups,
depending on the language you wish to use in your client-side code will
serve your purpose - hint: using vbscript will prevent the application
from working in non-IE browsers ...). I've never used activex components
due to the need for installing them on the client machines [1] so I am
unable to help with this issue.


[1] which is only going to get harder to do in the future given the focus
being put on browser security.

Bob Barrows


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
 
M

Mark J. McGinty

[comments posted inline]

Oscar said:
Hi Bob,

I've been able to draft an ASP page which opens a XML doc to retrieve the
recordset. It is able to display the recordset with the response object.

In this page there is an Active-X grid component (VSFlexgrid) which runs
at the client side and needs to be populated with the record data. I am
able to populate the grid with any data, but I can't refer to the
recordset object :

Of course not, you haven't created a recordset object on the client side,
there is nothing there for the client to see.

[snip]
So the client is able to see the rs object since it is able to navigate
through the records, but can't display the value of the field. Any
suggestions?

How do you figure? Every single access to the recordset object is inside of
<% %>. The only thing the client can see is the output generated on thge
server side. (See further comments inline.)


[snip]
<%
Dim rs
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open =Server.Mappath("db_xml.xml")


Do While not rs.EOF 'this works good
response.write (rs.Fields("naam") & " " & (rs.Fields("woonplaats")
& "<br>"))
rs.movenext
Loop

%>


<SCRIPT ID=clientEventHandlersVBS LANGUAGE=vbscript>
[snip]

<% rs.movefirst
Do While not rs.EOF %>

fg.additem <% rs.Fields("naam") %>

<% rs.movenext %>
<% Loop %>

[snip]

Just because this is in the client script block, does not make rs visible to
the client. The parts inside of <% %> run at the server. If you want to
create a recordset object on the client side, you need to send the XML down
to the client side, as part of the web page, like so:

[server side code]

rs.Save Response


[javascript client side code]

var rs = new ActiveXObject("ADODB.Recordset");
rs.Open(document.all.tags("XML")[0]);

Obviously if you have more than one XML element you'll have to manage them
in some way.

-Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top