Results 1 to 2 of 2

Thread: reconnecting with a data with asp

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Posts
    1
    Hi

    I have an asp page that connects to a database on load and displays the first recordset in a table, using

    <%
    set rs = server.createobject("adodb.recordset")
    sSQL = "qryContactDetails"
    sConn = "DSN=pubsource;UID=sa;PWD=12345"
    rs.open sSQL, sConn
    %>

    I then want to be able to move through the records, add, delete and amend via clicking on buttons - using -

    <SCRIPT LANGUAGE="VBScript">
    Sub btnFirst_onClick
    If rs.BOF = false Then
    rs.movefirst
    End If
    End sub

    Sub btnPrev_OnClick
    If rs.BOF = false Then
    rs.moveprevious
    End If
    End Sub

    Sub btnNext_OnClick
    rs.open sSQL, sConn
    If rs.EOF = false Then
    rs.movenext
    End If
    End Sub

    Sub btnLast_onClick
    If rs.EOF = false Then
    rs.movelast
    End If
    End sub
    </SCRIPT>

    <div id="Layer4" style="position:absolute; left:85px; top:418px; width:664px; height:44px; z-index:5">
    <form name="form1" >
    <input type="button" name="btnFirst" value="First Record">
    <input type="button" name="btnPrev" value="Previous Record">
    <input type="button" name="btnNext" value="Next Record">
    <input type="button" name="btnLast" value="Last Record">
    <input type="button" name="Print" value="Print">
    </form>
    </div>

    Whenever I click on a button I get 'object required 'rs''
    I presume this is because I've lost the connection or it's no longer recognised.

    How do I get round this - either by keeping the connection open or reopening it?

    TIA


  2. #2
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606
    Not sure of the problem but try this:

    <%
    Dim rs
    set rs = server.createobject("adodb.recordset")
    sSQL = "qryContactDetails"
    sConn = "DSN=pubsource;UID=sa;PWD=12345"
    rs.open sSQL, sConn
    %>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width