Can ADO Recordsets Created By ASP Be Used By JavaScript?

Discussion in 'ASP General' started by Eric Robinson, Sep 9, 2005.

  1. 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
     
    Eric Robinson, Sep 9, 2005
    #1
    1. Advertising

  2. 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/tips/xml.recordset.server2client.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.
     
    Bob Barrows [MVP], Sep 9, 2005
    #2
    1. Advertising

  3. 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]" <> wrote in message
    news:...
    > 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/tips/xml.recordset.server2client.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.
    >
    >
     
    Eric Robinson, Sep 9, 2005
    #3
  4. Eric Robinson

    Tim Slattery Guest

    "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)
     
    Tim Slattery, Sep 9, 2005
    #4
  5. Eric Robinson

    Hal Rosser Guest

    "Eric Robinson" <eric @ pmcipa..{com}> wrote in message
    news:1ZjUe.32660$...
    > 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.
     
    Hal Rosser, Sep 9, 2005
    #5
  6. Eric Robinson

    Curt_C [MVP] Guest

    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]" <> wrote in message
    > news:...
    > > 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/tips/xml.recordset.server2client.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.
    > >
    > >

    >
    >
    >
     
    Curt_C [MVP], Sep 9, 2005
    #6
  7. 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" <> wrote in message
    news:...
    > "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)
    >
     
    Eric Robinson, Sep 9, 2005
    #7
  8. 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:...
    > 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]" <> wrote in message
    >> news:...
    >> > 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/tips/xml.recordset.server2client.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.
    >> >
    >> >

    >>
    >>
    >>
     
    Eric Robinson, Sep 9, 2005
    #8
  9. 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:wJnUe.33196$...
    > 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:...
    >> 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]" <> wrote in message
    >>> news:...
    >>> > 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/tips/xml.recordset.server2client.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.
    >>> >
    >>> >
    >>>
    >>>
    >>>

    >
    >
     
    Eric Robinson, Sep 9, 2005
    #9
  10. 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/tips/xml.data.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/tips/xml.recordset.server2client.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/index.asp?pi=links&hp=links.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"
     
    Bob Barrows [MVP], Sep 10, 2005
    #10
  11. Eric Robinson

    Roland Hall Guest

    "Eric Robinson" <eric @ pmcipa..{com}> wrote in message
    news:xYnUe.33264$...
    :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
     
    Roland Hall, Sep 10, 2005
    #11
  12. Eric Robinson

    Bob Lehmann Guest

    >>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:nImUe.32860$...
    > 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" <> wrote in message
    > news:...
    > > "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)
    > >

    >
    >
     
    Bob Lehmann, Sep 11, 2005
    #12
  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:1ZjUe.32660$...
    > 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
    >
     
    Eric Robinson, Sep 12, 2005
    #13
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. nita
    Replies:
    1
    Views:
    898
    Saravana
    Nov 20, 2004
  2. ronaldlee

    Transfer ADO Code to ADO.NET

    ronaldlee, Dec 17, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    487
    Kevin Spencer
    Dec 17, 2004
  3. Replies:
    0
    Views:
    1,336
  4. Guy Cohen

    ADO+RECORDSETS

    Guy Cohen, Jan 18, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    380
    sloan
    Jan 19, 2007
  5. Casey Hawthorne
    Replies:
    1
    Views:
    744
    Arne Vajhøj
    Mar 18, 2009
Loading...

Share This Page