Results 1 to 3 of 3

Thread: Error using recordset object

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2001
    Posts
    101

    Error using recordset object

    Hello

    I am using Visual Interdev with IIS 5.0.I have a dataentry form where in
    when i click the button it has to go to the next record.

    My code is:

    <BODY>

    <%
    public cn, rst, strSQL
    Set cn = Server.CreateObject("ADODB.Connection")
    cn.ConnectionTimeout =30
    cn.open "FILEDSN=emp.dsn"
    Set rst = Server.CreateObject("ADODB.Recordset")

    strSQL = "SELECT * FROM employee"
    rst.Open strSQL,cn
    set txtemp_id.value = rst("emp_id")
    set txtemp_fname.value = rst("fname")
    set txtemp_lname.value = rst("lname")
    %>
    </BODY>


    The coding in the button is

    Sub btn_movenext_onclick()
    rst.Open '---> Line 14
    rst.MoveNext
    End Sub

    It is giving me the error :

    Error Type:
    Microsoft VBScript runtime (0x800A01A8)
    Object required: 'rst'
    emp_file.asp, line 14

    Please let me know where i could have done the mistake.
    Thanks

  2. #2
    Hyperactive Member ashay's Avatar
    Join Date
    Feb 2002
    Location
    Mumbai,India
    Posts
    278
    hi,

    hmmm.....u completley messed up with the code

    This is not the way to get the next record.Use paging to move to the next record.

    regds,
    ashay
    "If you should die before me, ask if you could bring a friend."
    - Stone Temple Pilots

  3. #3
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    You are trying to do a server side operation from the client side. You can't hold a recordset open in ASP and just movenext. Each time the server sends the page to the browser, the server is no longer aware of anything that was on that page, including your recordset. Recordsets do not live between pages. (Unless you do something you shouldn't like sticking it into the session object- don't do that.)
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

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