Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getobjectcontext returns nothing in vb?!?

Status
Not open for further replies.

vstewart

Programmer
Jan 21, 2002
2
CA
Hello all:
I'm having a problem that has stumped me for days, and I need help. Here is my code:

private function....
Dim objcontext As ObjectContext
Set objcontext = GetObjectContext()
On Error GoTo dataerrorhandler
Dim cmdstring
Dim oCn As ADODB.Connection
Dim oCM As ADODB.Command
cmdstring = "UPDATE TEST_WOrderTest SET
TEST_WOrderTest.OrderStatusUID = 2 WHERE
(TEST_WOrderTest.OrderUID <= &quot; & orderuid & &quot;)
and (TEST_WOrderTest.OrderStatusUID = 1)&quot;
Set oCn = CreateObject(&quot;ADODB.Connection&quot;)
Set oCM = CreateObject(&quot;ADODB.command&quot;)
oCn.ConnectionString= connectionstring....
oCn.CursorLocation = adUseClient
oCn.Open
With oCM
.ActiveConnection = oCn
.CommandType = adCmdText
.CommandText = cmdstring
.Execute
End With
oCn.Close
Set oCM = Nothing
Set oCn = Nothing

'everthing works, it updates the database and gets
'to this point just fine.

objcontext.SetComplete

'but this is where I get the error. #91: Object variable or
'with block variable not set. This is because
'getobjectcontext is returning nothing.

Exit Function
dataerrorhandler:
'abort the transaction
objcontext.SetAbort

End Function


I have the com+ services library referenced in my project, my component is intalled in component services and 'requires a new transaction' (I've also tried 'requires a transaction'), and I'm not calling this method from within the initialize or terminate events(which I know returns the same error.)


If anyone knows what this could be, it would be greatly appreciated.


Thank you very much

Victoria
 
Hi Victoria,
Do the Following Things
1. Check if Distributed Transaction Coordinator Server service is running.
2. Do not run ur ActiveX Dll project along with ur VB project as a group. Make the Dll and reference it to the VB project
 
I am having the same problem... should i avoid using GetObjectcontext() in com+ ?? what method should i use instead of GetObjectcontext()???
Thank u...

shrini
 
Actually, after much searching I came across an obscure reference to my problem in a .pdf based web article. Here is the address:
On the bottom of page three and the top of page four.
It turns out that there was nothing wrong with getobjectcontext, but when testing on my development machine, the component wasn't in a transaction. I think that my client app was using a local copy of the dll. (it was a while ago.) So, it actually worked just fine when I used it from the final app. In the end, I just tested to see if the object is in a transaction by checking if the context object returns nothing. If it does, then I return an error code to let the user know that the object is not in a transaction. This might not be the reason for your problem, but hopefully the article will help.

Thanks
Victoria
 
You should look at the following Microsoft article:

Bug: ObjectContext Item Collection Is Empty When You Debug Under COM+ (Q265492)

Basicaly you need to have VB Service Pack 3 or later

Ensure that the authenticating user has appropriate permissions.

Ensure that the component is deployed in a COM+ application.

Ensure that the component is set for binary compatibility.

Ensure that the component's MTS Transaction Mode is set to something other than 0 - NotAnMTSObject.

And viola it works.
 
Hi,

I m facing a similar kind of error.

But the thing is it my application is running fine on Win2k machines but the problem is with win98. I have installed DCOM98 as well as MDAC2.7 on win98. I face no problems in fetching the data. The error only occurs while updating the data or adding new data. Here the objectcontext comes into picture which is creating the problem.
I m getting the error 429 ActiveX cannot create object.

Please help me out to find the soultion of the problem
 
If you run your ActiveX DLL in the same project group as your client application what will happen is that the DLL will load into the clients address space and not have the COM+ features (ie ObjectContext) available. If you want to debug a COM+ component you have to debug it the way you would a ActiveX.exe.
1) start VB IDE with your COM+ component (must be in component services as a server packages)
2) run your component project (hitting wait for component to be created if prompted)
3) set your break points
4) run your client app in another VB IDE
 
Compile the dll, and put it in Com+ application. The error wil not occour. It occours only when your are not putting it in Com+ application.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top