Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

COM+ Visual basic

Posted on 2003-11-01
9
Medium Priority
?
405 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
[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
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
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Suggested Courses

721 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