Results 1 to 7 of 7

Thread: Checking if an Delete using ADO in a DLL was ok.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2002
    Location
    Uppsala, Sweden
    Posts
    20

    Question Checking if an Delete using ADO in a DLL was ok.

    Hi i have written an Dll for a project that takes care of all the database activity. I open the connection in the Class Initialize and use the same connection object for all methods in the DLL.
    Some of the methods return a disconnected recordset and some of the methods should just return True or false. Now to the problem I can´t get the hang of how I check that the Boolen set if I for example deletes a record. I have tried to use withevents on the connection object but I cant get it to work. If I have 3 methods accessing a equipment table in the db.
    1 . InsertEQ
    2. UpdateEQ
    3 . DeleteEQ

    All the actions should return booleans but the ExecuteCompleted method just checks the connection object not the individual methods, it would be good to have som error handeling also.
    Any ideas on how to do this..?

    /Henrik

  2. #2
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724
    Return enumerations
    VB Code:
    1. ' Declarations.
    2. Public Enum ReturnTypeConstants
    3.   rtOk = 0
    4.   rtFail = 1
    5.   rtError = 2
    6. End Enum
    7.  
    8. Public Function InsertEQ(Blah Blah Blah) As ReturnTypeConstants
    9.     Dim enReturn As ReturnTypeConstants
    10.  
    11.     On Error Goto InsertEQ_Error
    12.  
    13.     enReturn = rtFail ' Fails until success.
    14.     ' Your code....
    15.  
    16.     enReturn = rtOk
    17.  
    18.  
    19. InsertEQ_Error:
    20.     If Err.Number <> 0 Then
    21.         MsgBox Err.Number & " - " & Err.Description
    22.         Err.Clear
    23.         enReturn = rtError
    24.     End If
    25.  
    26.     ' Return.
    27.     InsertEQ = enReturn
    28. End Function

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Oct 2002
    Location
    Uppsala, Sweden
    Posts
    20
    Greate, thanx alot..

    One more question , if I expect a ADODB.Recordset back but something goes wrong. How can I tell the reciver that it went to the woods...

    /Henrik

  4. #4
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724
    In the procedure that does the returning, if anything goes "to the woods" set the recordset to Nothing & return it. At the client:
    VB Code:
    1. Set myRs = Proc()
    2. If myRs Is Nothing Then
    3.     MsgBox "It's all gone pear shaped."
    4. Else
    5.     ' Your processing goes here.
    6. End If

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Also, if there was an error during the execution of the SQL, the connection object has an Errors collection in it that will have the list of the error(s) that happened. By checking the Errors.Count you can tell if the SQL when tits up or not.
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Oct 2002
    Location
    Uppsala, Sweden
    Posts
    20
    But the connection object lies in the DLL , how do I access that.

    /H

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Oct 2002
    Location
    Uppsala, Sweden
    Posts
    20
    More questions..

    I have a Store Procedure that returns Multiple recordsets but when I try to pass them back I just get One of them and the error code:
    "Current provider does not support returning multiple recordsets from a singel execution"

    Is there a way of resolving this?

    /Henrik

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