Solved

COM+ Visual basic

Posted on 2003-11-01
9
396 Views
Last Modified: 2013-11-25
actually i am implementing  ObjectControl and my program calls this COM+ application the problem is i get a run time error saying that the object not set heres the code for my COM+ application

Implements ObjectControl
' Declare Object Context object
Private m_objContxt  As ObjectContext
Private m_strConnection As String
Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Private Sub ObjectControl_Activate()
Set m_objContxt = GetObjectContext
End Sub

Private Function ObjectControl_CanBePooled() As Boolean
 'For VB its always false so give that value
    ObjectControl_CanBePooled = False
End Function

Private Sub ObjectControl_Deactivate()
'Release the object context
 Set m_objContxt = Nothing
End Sub

Public Function TranferData(objTemp As Variant, strTableName As Variant) As Boolean
Dim objRsTemp As New Recordset
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset

On Error GoTo errorhandler
strConnection = GetConnectString()
conn.Open (strConnection)
Set rs = objTemp
         objRsTemp.CursorLocation = adUseClient
         objRsTemp.CursorType = adOpenDynamic
         objRsTemp.LockType = adLockBatchOptimistic
         objRsTemp.Open strTableName, conn
         
             'Copy to the temp recordset
            rs.MoveFirst
            Do Until rs.EOF
               objRsTemp.AddNew
                For intCount = 0 To rs.Fields.Count - 1
                    objRsTemp(intCount).Value = rs.Fields(intCount).Value
                Next
              rs.MoveNext
            Loop
      'Update
        'objRsTemp.Update
         objRsTemp.Properties("Update Criteria") = adCriteriaAllCols
         objRsTemp.UpdateBatch
         m_objContxt.SetComplete
         TranferData = True
       Exit Function
       
errorhandler:
m_objContxt.SetAbort
TranferData = False
Err.Raise Err.Number, , Err.Description



well i have registered this in Component service as i have got the msi file created then when my vb application calls this COM instead of first activating it directly executes the code in transfer data and finally when it tries m_objContxt.setComplete it gives a error object or variable not set can any one can sugesst me a ans for this

regards
srikanth

0
Comment
Question by:itssreekant
9 Comments
 
LVL 14

Expert Comment

by:aelatik
Comment Utility
Try changing : Private m_objContxt  As ObjectContext tp Private m_objContxt  As New ObjectContext
0
 
LVL 5

Expert Comment

by:rajaamirapu
Comment Utility
How did you registered the dll in com plus application?
0
 
LVL 5

Expert Comment

by:rajaamirapu
Comment Utility
Can you see your component under component services
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 75

Expert Comment

by:Anthony Perkins
Comment Utility
Why bother with your record of open questions:

1 01/13/2003 50 Saving & Retriving Images  Unlocked Oracle
2 01/15/2003 40 Progress Bar in D2k  Unlocked 3rd Party Applications and Development Tools
3 03/04/2003 75 Selecting n rows from a databse randomly  Unlocked Oracle
4 03/05/2003 100 Lan & Fibre Optics  Unlocked Networking
5 03/27/2003 75 Expecting the result in a single query  Unlocked Oracle
6 03/27/2003 75 Result in a single query  Unlocked Microsoft SQL Server
7 06/14/2003 100 XML-Encryption & Decryption  Unlocked XML
8 07/17/2003 100 Crystal reports 9 and Stored Procedure i...  Unlocked Crystal Reports
9 08/25/2003 100 xmlhttp  Unlocked Visual Basic
10 08/25/2003 100 xmlhttp / xml to recordset conversion  Unlocked Visual Basic

Anthony
0
 

Author Comment

by:itssreekant
Comment Utility
Hi all,
   Actually the problem was the property MtsTransactionMode  was set to NotAnMtsObject instead of RequiresNewTransaction  .Now the Problem is solved .

Thanks
Srikanth
0
 
LVL 75

Expert Comment

by:Anthony Perkins
Comment Utility
>>Now the Problem is solved .<<
Than please go ahead and close this question.

Thanks,
Anthony
0
 

Accepted Solution

by:
CetusMOD earned 0 total points
Comment Utility
PAQed, with points refunded (200)

CetusMOD
Community Support Moderator
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

772 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

10 Experts available now in Live!

Get 1:1 Help Now