RecordRef in 5.0

gulamdastagirgulamdastagir Member Posts: 411
hi

in 4.3 i have no problem running this code

Recref.OPEN(tableno)


but,in 5.0 i get an error
RecordRef variable has not been closed.You must close the RecordRef with close before opening a new table
Regards,

GD

Comments

  • raven44raven44 Member Posts: 85
    it seems as though there is already a Recref variable thats been opened.
    you could either close that recref first (although it may be required with other code).
    or specify another recref variable.
    Whereabouts is the code you're trying to execute?
  • gulamdastagirgulamdastagir Member Posts: 411
    I mean to say that there is nothing is wrong with the code as it runs perfectly on 4.3 database

    RecordRef.OPEN(tableno) is the point where i get the error message
    RecordRef variable has not been closed.You must close the RecordRef with close before opening a new table
    on a 5.0 DB[/code]
    Regards,

    GD
  • raven44raven44 Member Posts: 85
    could you post the code function that is giving you this error.
    also, is this standard NAV 5 or has any customizations been done to the object?
  • kinekine Member Posts: 12,562
    I mean to say that there is nothing is wrong with the code as it runs perfectly on 4.3 database

    RecordRef.OPEN(tableno) is the point where i get the error message
    RecordRef variable has not been closed.You must close the RecordRef with close before opening a new table
    on a 5.0 DB[/code]

    It seems that there is new check in NAV 5.0 and it is why "there is nothing wrong in NAV 4.0". If you are opening new record without closing previous one it leads to memory leaks, NAV 5.0 is checking this and it means you need to change your code to be able to run under NAV 5.0. That something works under older version and not under new one doesn't mean that there is bug or something, it can be new "feature"... 8)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • gulamdastagirgulamdastagir Member Posts: 411
    Exactly my thoughts i just needed an expert to confirm that thanks kine =D>
    Regards,

    GD
  • pdjpdj Member Posts: 643
    kine wrote:
    It seems that there is new check in NAV 5.0 and it is why "there is nothing wrong in NAV 4.0". If you are opening new record without closing previous one it leads to memory leaks, NAV 5.0 is checking this and it means you need to change your code to be able to run under NAV 5.0.
    Argh! How stupid ](*,)
    Why on earth did Microsoft "solve" it like this? Why didn't they simply always close RecordRefs before opening them? It should be possible to do very simple in the implementation of the OPEN function. Now all C/AL developers have to go through all the code using RecRef and insert a silly line before using this function. What a waste of time and a lot of changes in code that needs to be reviewed and tested and validated... #-o

    Edit: I thougt the problem was with both OPEN and GETTABLE, but it seems GETTABLE doesn't care if it has been used before. This makes it even more strange...
    Regards
    Peter
Sign In or Register to comment.