Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 19th, 2004, 05:59 AM
Authorized User
 
Join Date: Jan 2004
Location: lahore, punjab, Pakistan.
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default error 3219

I am navigatin through the record
NOTE :rsopen is an boolean variable and determines whether the record set is open or not rsopen = true means recordset is open
and right now ignore the parmaters that the rs_movenext and rs_moveback have.
table has only 2 records right now

Code:
Private Sub cmd_frm_pdev_add_Click(Index As Integer)
ElseIf cmd_frm_pdev_add(a + 1).Caption = "GO" Then
                        vmon = dtp_frm_pdev_pt.Month
                        vyear = Right(dtp_frm_pdev_pt.Year, 2)
                        dmon = vmon + "-" + vyear
                        qrystring = " select dmeeting,remarks from parent_teacher_meeting where substr(dmeeting,4,5) = '" & dmon & "' and student_id = '" & Val(txt_frm_pdev_studentid) & "'"
                        If rsopen = True Then
                            rs.Close
                            rsopen = False
                        End If
                        rs.Open qrystring, oconn
                        rsopen = True
                        If rs.EOF = False Then
                            dtp_frm_pdev_pt = CDate(rs.Fields(0).value)
                            txt_frm_pdev_comments = rs.Fields(1).value
                            'rs.Close
                            setctl_go (a + 1)
                        Else
                            rec_not_found
                            If rsopen = True Then
                                rs.Close
                                rsopen = False
                            End If
' Clear
                            Exit Sub
                        End If
end sub

Private Sub cmd_navl_Click(Index As Integer)
    n = SSTab1.Tab
    pichla rs, qrystring, n
End Sub

Private Sub cmd_navr_Click(Index As Integer)
    n = SSTab1.Tab
    rs_movenext rs, qrystring, n
End Sub

Private Sub rs_movenext(ByVal rs As ADODB.Recordset, ByVal qry As String, ByVal n As Integer)
    If rsopen = True Then
        If rs.EOF = False And rs.BOF = False Then
            Select Case n
                Case 1
                    rs.MoveNext
                    dtp_frm_pdev_pt = CDate(rs.Fields(0).value)
                    dmon = rs.Fields(0).value
                    txt_frm_pdev_comments = rs.Fields(1).value
                Case Else
            End Select
        End If
     End If
End Sub

Private Sub rs_moveback(ByVal rs As ADODB.Recordset, ByVal qry As String, ByVal n As Integer)
    If rsopen = True Then
        If rs.BOF = False Then 'And rs.EOF = True Then
            Select Case n
                Case 1
                    rs.MovePrevious
                    dtp_frm_pdev_pt = CDate(rs.Fields(0).value)
                    dmon = rs.Fields(0).value
                    txt_frm_pdev_comments = rs.Fields(1).value
                Case Else
            End Select
        End If
    End If
End Sub


the function rs_movenext works fine but it gave me error in rs_moveback at the line which is bold. whether the rs_movenext has been called before this or not.
Run time error "operation is not allowed in this context. "
rs is the global veriable (for this form)
I searched the msdn (internet) but can't find any reason & possible solution
Private Sub cmd_frm_pdev_add_Click(Index As Integer) is the function that builds the rs
Reply With Quote
  #2 (permalink)  
Old January 19th, 2004, 11:56 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Sounds like you have the wrong cursor type. When you use syntax like this
Code:
rs.Open qrystring, oconn
to open a recordset you get the default forward-only cursor (so you can't MovePrevious)
change it to another cursor type, for example
Code:
rs.Open qrystring, oconn, adOpenStatic
Reply With Quote
  #3 (permalink)  
Old January 20th, 2004, 03:52 AM
Authorized User
 
Join Date: Jan 2004
Location: lahore, punjab, Pakistan.
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by pgtips
 Sounds like you have the wrong cursor type. When you use syntax like this
Code:
rs.Open qrystring, oconn
to open a recordset you get the default forward-only cursor (so you can't MovePrevious)
change it to another cursor type, for example
Code:
rs.Open qrystring, oconn, adOpenStatic
Lets Suppose I have 2 records (the query in the above code return these)
one for the date 31-01-99
and ohter for 29-02-99
now say the first record it shows is 31-01-99
then press move next button it showed me the next record , If I again press the movenext buton it gives me error
"Either EOF or BOF is true, or the current record has been deleted, Requested operation requires the surrent recoed"
Same is the case with moveback buuton
Now How Can I remove this error (Plz refer to the code(rs_movenext , rs_moveback) I've given above and consider the line "rs.Open qrystring, oconn " as
 "rs.Open qrystring, oconn, adOpenStatic")




Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Parse error: syntax error, unexpected T_ELSE in /h vipin k varghese BOOK: XSLT Programmer's Reference, 2nd Edition 4 September 29th, 2011 01:19 AM
Insert Query Error & Run-Time Error 3022 DavidWE Access 1 July 31st, 2008 11:17 AM
Ch 4: Parse error: syntax error, unexpected T_SL hanizar77 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 June 23rd, 2008 09:17 PM
3219 Error: Operation Not Allowed in this Context dolfandave VB Databases Basics 0 May 17th, 2005 10:09 AM
Phile Page error, visual studio error reps BOOK: ASP.NET Website Programming Problem-Design-Solution 0 September 27th, 2003 10:11 AM



All times are GMT -4. The time now is 09:24 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.