|
-
Jan 17th, 2003, 06:48 AM
#1
Thread Starter
Junior Member
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
-
Jan 17th, 2003, 07:53 AM
#2
Return enumerations 
VB Code:
' Declarations.
Public Enum ReturnTypeConstants
rtOk = 0
rtFail = 1
rtError = 2
End Enum
Public Function InsertEQ(Blah Blah Blah) As ReturnTypeConstants
Dim enReturn As ReturnTypeConstants
On Error Goto InsertEQ_Error
enReturn = rtFail ' Fails until success.
' Your code....
enReturn = rtOk
InsertEQ_Error:
If Err.Number <> 0 Then
MsgBox Err.Number & " - " & Err.Description
Err.Clear
enReturn = rtError
End If
' Return.
InsertEQ = enReturn
End Function
-
Jan 17th, 2003, 09:25 AM
#3
Thread Starter
Junior Member
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
-
Jan 17th, 2003, 09:30 AM
#4
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:
Set myRs = Proc()
If myRs Is Nothing Then
MsgBox "It's all gone pear shaped."
Else
' Your processing goes here.
End If
-
Jan 17th, 2003, 09:34 AM
#5
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.
-
Jan 17th, 2003, 09:53 AM
#6
Thread Starter
Junior Member
But the connection object lies in the DLL , how do I access that.
/H
-
Jan 17th, 2003, 11:54 AM
#7
Thread Starter
Junior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|