?
Solved

RunTime Error

Posted on 2002-07-06
3
Medium Priority
?
150 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 400 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month11 days, 18 hours left to enroll

752 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