Recordset zur Laufzeit aktuallisieren

  • VB6

Es gibt 5 Antworten in diesem Thema. Der letzte Beitrag () ist von andi25.

    Recordset zur Laufzeit aktuallisieren

    Hallo,

    ich öffne auf folgende Weise beim Laden eines Formulars ein Recordset:


    Visual Basic-Quellcode

    1. Set RsSIM.ActiveConnection = Cn
    2. RsSIM.LockType = adLockOptimistic
    3. RsSIM.Source = "SELECT tab_SIM.SIM FROM tab_SIM WHERE personaNR=" & actualID
    4. RsSIM.Open


    Nun möchte ich das Recordset zur Laufzeit neu laden (weil sich die Variable actualID ändert). Weiß jemand, wie ich das machen könnte?

    Wenn ich es erneut öffne, bekomme ich eine Meldung, dass es bereits geöffnet ist...

    Vielen Dank, Andi
    Hallo Der_Wanderer!

    Danke für Deine Antwort! Ja, das hab ich schon versucht:

    Visual Basic-Quellcode

    1. actualID = Rs.Fields("personaID")
    2. Set RsSIM.ActiveConnection = Cn
    3. RsSIM.LockType = adLockOptimistic
    4. RsSIM.Source = "SELECT tab_SIM.SIM FROM tab_SIM WHERE personaNR=" & actualID
    5. RsSIM.Close
    6. RsSIM.Open
    7. Set grdSIM.DataSource = Nothing
    8. Set grdSIM.DataSource = RsSIM


    Leider bekomme ich dann in der Zeile, in der ich das Recordset schließe die Meldung "Diese Operation ist für ein geschlossenes Recordset nicht erlaubt"

    Viele Grüße, Andi
    Ah, ok, jetzt klappt es:

    Visual Basic-Quellcode

    1. Set grdSIM.DataSource = Nothing
    2. actualID = Rs.Fields("personaID")
    3. Set RsSIM.ActiveConnection = Cn
    4. RsSIM.LockType = adLockOptimistic
    5. RsSIM.Source = "SELECT * FROM tab_SIM WHERE personaNR=" & actualID
    6. RsSIM.Open
    7. Set grdSIM.DataSource = RsSIM


    Danke und viele Grüße, Andi