473,399 Members | 2,278 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,399 software developers and data experts.

Can ADO Recordsets Created By ASP Be Used By JavaScript?

Hello,

My ASP code creates an ADO recordset object on the server.

Later on the same page, I have a javascript code snippet that I use to
dynamically populate a drop-down box based on choices made in another
drop-down box. Can this javascript (or a server-side equivalent) access the
recordset object?

--Eric
Sep 9 '05 #1
13 2451
Eric Robinson wrote:
Hello,

My ASP code creates an ADO recordset object on the server.

Later on the same page, I have a javascript code snippet that I use to
dynamically populate a drop-down box based on choices made in another
drop-down box. Can this javascript (or a server-side equivalent)
access the recordset object?

Only if it is passed to the client-side code. I tend to avoid trying to use
ADO on the client, preferring to use XML, but here's one way to do it (this
example uses vbscript in the client-side script but it can easily be
rewritten to use jscript instead):

http://www.davidpenton.com/testsite/...ver2client.asp

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Sep 9 '05 #2
Hi,

My question was confusing because I myself am a little confused. I am not
using ADO on the client. The ADO connection and recordset are instantiated
on the server through ASP. My question is, can a server-side Javascript use
a server-side object that was created earlier on the same page by ASP code?
Or does the server-side Javascript have to instantiate its own separate
connection and recordset objects?

--Eric

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:OU**************@TK2MSFTNGP14.phx.gbl...
Eric Robinson wrote:
Hello,

My ASP code creates an ADO recordset object on the server.

Later on the same page, I have a javascript code snippet that I use to
dynamically populate a drop-down box based on choices made in another
drop-down box. Can this javascript (or a server-side equivalent)
access the recordset object?

Only if it is passed to the client-side code. I tend to avoid trying to
use
ADO on the client, preferring to use XML, but here's one way to do it
(this
example uses vbscript in the client-side script but it can easily be
rewritten to use jscript instead):

http://www.davidpenton.com/testsite/...ver2client.asp

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Sep 9 '05 #3
"Eric Robinson" <eric @ pmcipa..{com}> wrote:
My question was confusing because I myself am a little confused. I am not
using ADO on the client. The ADO connection and recordset are instantiated
on the server through ASP. My question is, can a server-side Javascript use
a server-side object that was created earlier on the same page by ASP code?
Or does the server-side Javascript have to instantiate its own separate
connection and recordset objects?


By the time client-side Javascript runs, all ASP code - whether
VBScript, Javascript, or another language - has finished and no longer
exists. That being the case, there's no way client-side Javascript can
use any ASP object.

--
Tim Slattery
MS MVP(DTS)
Sl********@bls.gov
Sep 9 '05 #4

"Eric Robinson" <eric @ pmcipa..{com}> wrote in message
news:1Z*******************@fe05.lga...
Hello,

My ASP code creates an ADO recordset object on the server.

Later on the same page, I have a javascript code snippet that I use to
dynamically populate a drop-down box based on choices made in another
drop-down box. Can this javascript (or a server-side equivalent) access the recordset object?

in short - No - (but)
but in a disconnected way, -
that is, you can use ASP to create javascript arrays to hold the data which
javascript can then use -
howsomever - keep in mind that the javascript code won't be able to access
the database.
remember - once the user has received the page - its on his computer, and
not the server.
The user's browser is rendering a page which is the 'result' - or output
from an ASP script.
Javascript executes in the user's browser.
Sep 9 '05 #5
If its not in the same code its not usable. You will have to pass it (session
perhaps, etc) to get at it. I'm not sure how you are havinging seperate
serverside javascript though.. is it in include?

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"Eric Robinson" wrote:
Hi,

My question was confusing because I myself am a little confused. I am not
using ADO on the client. The ADO connection and recordset are instantiated
on the server through ASP. My question is, can a server-side Javascript use
a server-side object that was created earlier on the same page by ASP code?
Or does the server-side Javascript have to instantiate its own separate
connection and recordset objects?

--Eric

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:OU**************@TK2MSFTNGP14.phx.gbl...
Eric Robinson wrote:
Hello,

My ASP code creates an ADO recordset object on the server.

Later on the same page, I have a javascript code snippet that I use to
dynamically populate a drop-down box based on choices made in another
drop-down box. Can this javascript (or a server-side equivalent)
access the recordset object?

Only if it is passed to the client-side code. I tend to avoid trying to
use
ADO on the client, preferring to use XML, but here's one way to do it
(this
example uses vbscript in the client-side script but it can easily be
rewritten to use jscript instead):

http://www.davidpenton.com/testsite/...ver2client.asp

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


Sep 9 '05 #6
Forgive me for belaboring the issue, but you said:

"By the time client-side Javascript runs, all ASP code -
whether VBScript, Javascript, or another language - has finished..."

I understand that, but my real question is in reference to all SERVER-side
code.

Is it possible for JavaScript code running on the server to call methods in
objects instantiated by ASP code running on the server?

"Tim Slattery" <Sl********@bls.gov> wrote in message
news:3k********************************@4ax.com...
"Eric Robinson" <eric @ pmcipa..{com}> wrote:
My question was confusing because I myself am a little confused. I am not
using ADO on the client. The ADO connection and recordset are instantiated
on the server through ASP. My question is, can a server-side Javascript
use
a server-side object that was created earlier on the same page by ASP
code?
Or does the server-side Javascript have to instantiate its own separate
connection and recordset objects?


By the time client-side Javascript runs, all ASP code - whether
VBScript, Javascript, or another language - has finished and no longer
exists. That being the case, there's no way client-side Javascript can
use any ASP object.

--
Tim Slattery
MS MVP(DTS)
Sl********@bls.gov

Sep 9 '05 #7
I'm probably goping about this all wrong and making it too hard. The
situation is pretty basic. In ASP I create two server-side recordsets, which
I'll call rsCircuses and rsClowns.

The records in rsCircuses look like this:

ID CircusName
1 Ringling Brothers
2 Barnum and Bailey
3 Circus Circus
4 Cirque du Soliel
5 etc.

The records in rsClowns look like this:

ID ClownName CircusID
1 Bozo 2
2 Dopey 4
3 Bingo 2
4 Poo Poo 3
5 etc.

rsCircuses is used to populate a drop-down menu. When the user chooses a
circus from the menu, I want to populate the second drop-down with records
picked from rsClowns based on the CircusID.

I was able to populate the first drop-down from rsCircuses, but I cannot
figure a way to populate the second drop-down based on a database query.

"Curt_C [MVP]" <software_at_darkfalz.com> wrote in message
news:5A**********************************@microsof t.com...
If its not in the same code its not usable. You will have to pass it
(session
perhaps, etc) to get at it. I'm not sure how you are havinging seperate
serverside javascript though.. is it in include?

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"Eric Robinson" wrote:
Hi,

My question was confusing because I myself am a little confused. I am not
using ADO on the client. The ADO connection and recordset are
instantiated
on the server through ASP. My question is, can a server-side Javascript
use
a server-side object that was created earlier on the same page by ASP
code?
Or does the server-side Javascript have to instantiate its own separate
connection and recordset objects?

--Eric

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:OU**************@TK2MSFTNGP14.phx.gbl...
> Eric Robinson wrote:
>> Hello,
>>
>> My ASP code creates an ADO recordset object on the server.
>>
>> Later on the same page, I have a javascript code snippet that I use to
>> dynamically populate a drop-down box based on choices made in another
>> drop-down box. Can this javascript (or a server-side equivalent)
>> access the recordset object?
>>
> Only if it is passed to the client-side code. I tend to avoid trying to
> use
> ADO on the client, preferring to use XML, but here's one way to do it
> (this
> example uses vbscript in the client-side script but it can easily be
> rewritten to use jscript instead):
>
> http://www.davidpenton.com/testsite/...ver2client.asp
>
> Bob Barrows
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.
>
>


Sep 9 '05 #8
I think I got it.

I did everything on the server with ASP, but in the ASP code I actually
wrote out a client-side JavaScript, like this:

<%
Response.Write "<script language=""javascript"">"
Response.Write (... the javascript drop-down box code...)
Response.Write "</script>"
%>

It may be yoogly but it seems to work.

"Eric Robinson" <eric @ pmcipa..{com}> wrote in message
news:wJ*******************@fe05.lga...
I'm probably goping about this all wrong and making it too hard. The
situation is pretty basic. In ASP I create two server-side recordsets,
which I'll call rsCircuses and rsClowns.

The records in rsCircuses look like this:

ID CircusName
1 Ringling Brothers
2 Barnum and Bailey
3 Circus Circus
4 Cirque du Soliel
5 etc.

The records in rsClowns look like this:

ID ClownName CircusID
1 Bozo 2
2 Dopey 4
3 Bingo 2
4 Poo Poo 3
5 etc.

rsCircuses is used to populate a drop-down menu. When the user chooses a
circus from the menu, I want to populate the second drop-down with records
picked from rsClowns based on the CircusID.

I was able to populate the first drop-down from rsCircuses, but I cannot
figure a way to populate the second drop-down based on a database query.

"Curt_C [MVP]" <software_at_darkfalz.com> wrote in message
news:5A**********************************@microsof t.com...
If its not in the same code its not usable. You will have to pass it
(session
perhaps, etc) to get at it. I'm not sure how you are havinging seperate
serverside javascript though.. is it in include?

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"Eric Robinson" wrote:
Hi,

My question was confusing because I myself am a little confused. I am
not
using ADO on the client. The ADO connection and recordset are
instantiated
on the server through ASP. My question is, can a server-side Javascript
use
a server-side object that was created earlier on the same page by ASP
code?
Or does the server-side Javascript have to instantiate its own separate
connection and recordset objects?

--Eric

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:OU**************@TK2MSFTNGP14.phx.gbl...
> Eric Robinson wrote:
>> Hello,
>>
>> My ASP code creates an ADO recordset object on the server.
>>
>> Later on the same page, I have a javascript code snippet that I use
>> to
>> dynamically populate a drop-down box based on choices made in another
>> drop-down box. Can this javascript (or a server-side equivalent)
>> access the recordset object?
>>
> Only if it is passed to the client-side code. I tend to avoid trying
> to
> use
> ADO on the client, preferring to use XML, but here's one way to do it
> (this
> example uses vbscript in the client-side script but it can easily be
> rewritten to use jscript instead):
>
> http://www.davidpenton.com/testsite/...ver2client.asp
>
> Bob Barrows
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.
>
>


Sep 9 '05 #9
Eric Robinson wrote:
I'm probably goping about this all wrong and making it too hard. The
situation is pretty basic. In ASP I create two server-side
recordsets, which I'll call rsCircuses and rsClowns.

The records in rsCircuses look like this:

ID CircusName
1 Ringling Brothers
2 Barnum and Bailey
3 Circus Circus
4 Cirque du Soliel
5 etc.

The records in rsClowns look like this:

ID ClownName CircusID
1 Bozo 2
2 Dopey 4
3 Bingo 2
4 Poo Poo 3
5 etc.

rsCircuses is used to populate a drop-down menu. When the user
chooses a circus from the menu, I want to populate the second
drop-down with records picked from rsClowns based on the CircusID.


This i where client-side code is required (unless you want to submit back to
the server when the user picks a circus). Only client-side code can respond
to user events without involving a submission to a server page.

My preferred technique is to pass an xml document containing the clowns data
to the client-side jscript code, either via a data island (IE-only; see
http://www.davidpenton.com/testsite/...ta.islands.asp) or by
response.writing a string containing the xml into a variable in a clientside
code block which is the techniques used in this example:
http://www.davidpenton.com/testsite/...ver2client.asp
Youcan also use the xmlhttprequest object to request data from server pages
without submitting your form. This technique is illustrated in the dynamic
listbox demo which can be downloaded from here:
http://www.thrasherwebdesign.com/ind...asp&c=&a=clear

For further questions about the client-side code, you need to post to a
relevant newsgroup. I suggest m.p.scripting.jscript.

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"
Sep 10 '05 #10
"Eric Robinson" <eric @ pmcipa..{com}> wrote in message
news:xY******************@fe05.lga...
:I think I got it.
:
: I did everything on the server with ASP, but in the ASP code I actually
: wrote out a client-side JavaScript, like this:
:
: <%
: Response.Write "<script language=""javascript"">"
: Response.Write (... the javascript drop-down box code...)
: Response.Write "</script>"
: %>
:
: It may be yoogly but it seems to work.

I'm not sure what yoogly is but there is no ASP vs javascript code. Replace
ASP with VBScript.
And, in your client-side script block, use <script type="text/javascript">
language= is deprecated on the client-side.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Sep 10 '05 #11
Eric Robinson wrote:
Forgive me for belaboring the issue, but you said:

"By the time client-side Javascript runs, all ASP code -
whether VBScript, Javascript, or another language - has
finished..."

I understand that, but my real question is in reference
to all SERVER-side code.

Is it possible for JavaScript code running on the server
to call methods in objects instantiated by ASP code running
on the server?


JScript, yes. JavaScript, no. All of my ASP scripts are written in JScript.

But this suggests you don't fully understand the dynamic between client-side
and server-side code:

"My ASP code creates an ADO recordset object on the server.

Later on the same page, I have a javascript code snippet
that I use to dynamically populate a drop-down box based
on choices made in another drop-down box. Can this
javascript (or a server-side equivalent) access the
recordset object?"

There is no such thing as "later on in the same page", as far as server-side
objects care. Those objects (including the implicit Request, Response,
Server and Session objects, not to mention the ones you explicitly created)
are all GONE before <html> is parsed by the browser. They are LONG GONE by
the time <select> is parsed, EXTRA LONG GONE by the time your browser
renders the select element onscreen, and EXTRA-EXTRA LONG GONE by the time a
client event is fired.
--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Sep 10 '05 #12
>>Is it possible for JavaScript code running on the server to call methods
in objects instantiated by ASP code running on the server?

What's the difference between "JavaScript code running on the server " and
ASP code? Isn't code running on the server already ASP code?

Bob Lehmann

"Eric Robinson" <eric @ pmcipa..{com}> wrote in message
news:nI*******************@fe05.lga...
Forgive me for belaboring the issue, but you said:

"By the time client-side Javascript runs, all ASP code -
whether VBScript, Javascript, or another language - has finished..."

I understand that, but my real question is in reference to all SERVER-side
code.

Is it possible for JavaScript code running on the server to call methods in objects instantiated by ASP code running on the server?

"Tim Slattery" <Sl********@bls.gov> wrote in message
news:3k********************************@4ax.com...
"Eric Robinson" <eric @ pmcipa..{com}> wrote:
My question was confusing because I myself am a little confused. I am notusing ADO on the client. The ADO connection and recordset are instantiatedon the server through ASP. My question is, can a server-side Javascript
use
a server-side object that was created earlier on the same page by ASP
code?
Or does the server-side Javascript have to instantiate its own separate
connection and recordset objects?


By the time client-side Javascript runs, all ASP code - whether
VBScript, Javascript, or another language - has finished and no longer
exists. That being the case, there's no way client-side Javascript can
use any ASP object.

--
Tim Slattery
MS MVP(DTS)
Sl********@bls.gov


Sep 10 '05 #13
I have been saying "ASP" when I often meant server-side Never having written
anything in Jscript, I had Vbscript and ASP tied together in my mind.
Vbscript. Sorry about that. Anyway, the problem is solved. Thanks for all
the feedback.

"Eric Robinson" <eric @ pmcipa..{com}> wrote in message
news:1Z*******************@fe05.lga...
Hello,

My ASP code creates an ADO recordset object on the server.

Later on the same page, I have a javascript code snippet that I use to
dynamically populate a drop-down box based on choices made in another
drop-down box. Can this javascript (or a server-side equivalent) access
the recordset object?

--Eric

Sep 12 '05 #14

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

Similar topics

22
by: James Cane | last post by:
Here's an interesting problem that someone might have an answer to... Some time ago, I wrote a set of utility classes which wrap up the custom row source function needed to add arbitrary items to...
6
by: Steve Jorgensen | last post by:
I keep having problems in which ADO disconnected recordset work under some circumstances, but lose all their data at other times, having no rows or fields, though the recordset object still exists....
13
by: Peter Bailey | last post by:
I have used recordsets in my query but only referenceing an sql string and not a query. I tried to reference a query that was created but it falls over. I have that works: dim Rst2 as...
2
by: Pieter Linden | last post by:
The answer to this one is probably "test it yourself and find out!", but I'll ask anyway. Pursuant to my previous question - sending separate recordsets to Word using the CreateTableFromRecordset...
16
by: Randy Harris | last post by:
I was inspired by the recent discussion of returning multiple recordsets to ADO from a stored procedure. (Amazed is probably more accurate). I asked about how to accomplish same with Oracle and...
34
by: Jeff | last post by:
For years I have been using VBA extensively for updating data to tables after processing. By this I mean if I had to do some intensive processing that resulted in data in temp tables, I would have...
24
by: Donald Grove | last post by:
I want to populate an array with values from an ado recordset (multiple rows) I use the absolute position of the cursor in the recordset to define the row of my array to be populated. I have a...
9
ADezii
by: ADezii | last post by:
There are basically 4 Methods that you can use to access the values of Fields in Recordsets. For the purposes of this demonstration, I'll be using a Table called tblEmployees, a Field named , and a...
11
by: BeckR | last post by:
Hello - Thanks for reading my post. I am a newbie when it comes to VBA programming, but have managed to do what I need to do, until now. I have an Access 2000 database (running WinXP Pro...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.