Solved

COM+ Visual basic

Posted on 2003-11-01
9
399 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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 …
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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 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…

828 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