Results 1 to 8 of 8

Thread: Opening and closing a recordset in VB6 [Resolved]

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    116

    Resolved Opening and closing a recordset in VB6 [Resolved]

    Hi,

    I'm developing a database application in Visual Basic 6 and there are some occaisions where I need to execute two different queries on different tables. When I try and close the recordset I'm using to do the first query for the second query, I get an error saying that the recordset is already closed, despite the fact that I have just opened it.

    VB Code:
    1. Private Sub DoUpdate(ByVal objConn as ADODB.Connection, _
    2.   ByVal strSurname as String, ByVal strNew as String, _
    3.   ByVal intID as Integer)
    4. Dim objRS as ADODB.Recordset
    5.  
    6. Set objRS = New ADODB.Recordset
    7.  
    8. objRS.Open "INSERT INTO Members(Surname) VALUES('" & strSurname & "');", _
    9.   objConn, adOpenStatic, adLockPessimistic
    10.  
    11. objRS.Close
    12.  
    13. objRS.Open "UPDATE Register SET NewUser='" & strNew & _
    14.   "' WHERE MemID=" & intID & ";", objConn, adOpenStatic, adLockPessimistic
    15.  
    16. objRS.Close
    17.  
    18. End Sub

    Any ideas?
    Last edited by olamm2k; Mar 10th, 2005 at 02:08 PM.

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