Solved

COM+ Visual basic

Posted on 2003-11-01
9
397 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
ID: 9662469
Try changing : Private m_objContxt  As ObjectContext tp Private m_objContxt  As New ObjectContext
0
 
LVL 5

Expert Comment

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

Expert Comment

by:rajaamirapu
ID: 9662518
Can you see your component under component services
0
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.

 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 9663909
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
ID: 9683993
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
ID: 9684295
>>Now the Problem is solved .<<
Than please go ahead and close this question.

Thanks,
Anthony
0
 

Accepted Solution

by:
CetusMOD earned 0 total points
ID: 10651877
PAQed, with points refunded (200)

CetusMOD
Community Support Moderator
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

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…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
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…

920 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

15 Experts available now in Live!

Get 1:1 Help Now