Solved

RunTime Error

Posted on 2002-07-06
3
143 Views
Last Modified: 2010-05-02
i implemented my Application using Com+, i'm getting this error:Run time error "3251": ....etc.
i checked this link:
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q201716.
and i checked my code it contains the following:

Private Sub ObjectControl_Activate()
Set Cnn = New ADODB.Connection
Set Cmd = New ADODB.Command
On Error GoTo Err_Cnn
    Cnn.Open connstr
Exit Sub
Err_Cnn:
   ChkVal = 1
Set mV2 = GetObjectContext()
  End Sub


Public Function OpenRecordSet(spName As String, ParamArray AttachedParameters() As Variant) As ADODB.Recordset
'Dim MyRec As ADODB.Recordset
Set Rs = New ADODB.Recordset
Dim i As Long
If Rs.State = adStateOpen Then
   Rs.Close
End If
With Rs
    .CursorType = adOpenKeyset
    .LockType = adLockOptimistic
    .CursorLocation = adUseClient  '<-- Add this line
End With

On Error GoTo ERRORHANDLER
     Cmd.CommandTimeout = 3600
     Cmd.ActiveConnection = Cnn
     Cmd.CommandType = 4 'Stored Procedure
     Cmd.CommandText = Trim(spName)
        If UBound(AttachedParameters) >= 0 Then
            Cmd.Parameters.Refresh
            For i = 0 To UBound(AttachedParameters)
                Cmd.Parameters(i + 1).Value = AttachedParameters(i)
            Next i
        End If
     Rs.Open Cmd
     Set OpenRecordSet = Rs
     Exit Function
ERRORHANDLER:
    Set OpenRecordSet = Nothing
    End If
End Function

Private Sub ObjectControl_Deactivate()
    Set Cnn = Nothing
    Set Cmd = Nothing
    Set Rs = Nothing
    Set mV2 = Nothing
End Sub
........ i tried to comment the deactivate Sub as to keep the record connected but still i'm getting the error:-(
Any Help!!!!!
Regards Meer.
0
Comment
Question by:mirghani
3 Comments
 
LVL 22

Accepted Solution

by:
Mohammed Nasman earned 100 total points
ID: 7134215
0
 

Author Comment

by:mirghani
ID: 7134643
i tried the link but still:-(
if i set the CursorLocation=adUseServer it will not work at all!!!!!
any help.....?
Meer.
0
 
LVL 5

Expert Comment

by:rpai
ID: 7137874
Do you know what line of code raises the error? And how are Cmd and Cnn declared?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VBA saving file message display 5 56
JSON Response and request in VB6 application 11 250
Adding to a VBA? 6 62
SLMGR Switches Are Not Working On KMS Host 3 69
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now