Solved

RunTime Error

Posted on 2002-07-06
3
148 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

726 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