Function sequence error
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: Function sequence error

  1. #1
    Join Date
    Aug 2002
    Posts
    640

    Function sequence error

    Hi,
    My application connects to MS SQL Server performs some queries and then disconnects and finishes.

    Upon disconnecting I'm releasing all handles that I allocated on connection. Unfortunately when releasing the very last one (environment handle) I'm getting "Function sequence error".

    Now my question is - Since it is MS SQL Server I'm allocating many different connection and statement handles and then release them afterwards.

    Is there a way for me to get which function didn't close the connection or release HDBC handle?

    If there is none - what would you recommend for the debugging this issue? Moving thru the code would be hard as it is a big code (even though I wrote all of it) and I'm afraid I may just inadvertently skip the error.

    Thank you for any pointers.

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    12,555

    Re: Function sequence error

    I forget, are you limited to C in this project?

  3. #3
    Join Date
    Aug 2002
    Posts
    640

    Re: Function sequence error

    Hi,
    Quote Originally Posted by Arjay View Post
    I forget, are you limited to C in this project?
    Nope. It is C++ one.

    But ODBC API is C one.

    Thank you.

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    12,555

    Re: Function sequence error

    I have to wonder why you are using raw ODBC when there are C++ alternatives like OleDb and the ATL consumer classes where the programmer doesn't have to handle every aspect of allocating memory for data retrieval. Since these alternatives are in C++, the class destructors handle the cleanup.

    I find the ATL Consumer classes particularly easy to work with. As there is a wizard the allows you to point to a view, sproc or table and the necessary classes are generated and added to your project.

  5. #5
    Join Date
    Aug 2002
    Posts
    640

    Re: Function sequence error

    Hi, Arjay,
    Quote Originally Posted by Arjay View Post
    I have to wonder why you are using raw ODBC when there are C++ alternatives like OleDb and the ATL consumer classes where the programmer doesn't have to handle every aspect of allocating memory for data retrieval. Since these alternatives are in C++, the class destructors handle the cleanup.
    Is OLEDB and ATL cross-platform solutions? Cross-DB solutions?

    Quote Originally Posted by Arjay View Post
    I find the ATL Consumer classes particularly easy to work with. As there is a wizard the allows you to point to a view, sproc or table and the necessary classes are generated and added to your project.
    Is there an alternatives for *nix/OSX to those 2 above?

    Thank you.

  6. #6
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    12,555

    Re: Function sequence error

    Quote Originally Posted by OneEyeMan View Post
    Is OLEDB and ATL cross-platform solutions?
    Is there an alternatives for *nix/OSX to those 2 above?

    Thank you.
    Historically, the Visual C++ Programming forum has implied Windows as the platform and the use of frameworks such as MFC and ATL. I suppose with the cross platform support in VS 2017, this has changed. Both OleDb and ATL rely on COM so cross platform for each is out. Really a shame to have to manually do this with ODBC.

  7. #7
    Join Date
    Aug 2002
    Posts
    640

    Re: Function sequence error

    Arjay,
    So now back to my question - is there a way to debug this that does not involve going thru the code manually?

    Thank you.

  8. #8
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    12,555

    Re: Function sequence error

    Quote Originally Posted by OneEyeMan View Post
    Arjay,
    So now back to my question - is there a way to debug this that does not involve going thru the code manually?

    Thank you.
    It would be good to structure the ODBC code into classes and leverage the destructors to clean up any allocated memory or handles.

    Of course, if this has not been done, then you'll need to track down the issues manually. If you have put the ODBC code into its own dll, then perhaps you can isolate the problems with some specific tests?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This a Codeguru.com survey!


On-Demand Webinars (sponsored)