473,385 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

GetObjectContext problems when calling COM+ components from .NET

6
I am working with a system using a Com+ layer built in VB6. I am now trying to use these components from VB.Net.
I have added the component as reference and .Net seem to communicate with the component.

I am using the following code to connect:
Expand|Select|Wrap|Line Numbers
  1. Dim adm_event As Admin.Event
  2. adm_event = CreateObject("admin.event")
  3.  
While running the procedure I get the error:
ErrorCode=-2147467259
Message="[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied."
Source="Microsoft OLE DB Provider for SQL Server"

The connection string is stored in Global,asa as well as a few other parameters.
Expand|Select|Wrap|Line Numbers
  1.     Set objContext = GetObjectContext()
  2.     connstring = objContext.Item("Application")("connstring")
  3.  
I think it's this part that doesn't work.

It's important to get this working because we shall reuse a lot of Com+ components while beginning the migration to .Net

I really appreciate any help on this. I have not worked much with VB.Net yet, but have searched a lot to find a solution, without luck :-(

Lage
Sep 24 '08 #1
4 2642
mldisibio
190 Expert 100+
Without seeing any code I cannot be certain, but it looks like your .Net app is picking up the connection string from the COM component just fine. The error you are receiving is occuring in an attempt to resolve the connection string.

Perhaps the syntax in the COM Component for the connection string needs to be modified for the .Net SqlConnection to parse it correctly.

If you add some Debug.Write(connectionString) code to your .Net in the method where SqlConnection.Open is called, you can print out the ConnectionString it is trying to resolve. If the problem is not obvious, post the results of the Debug output and someone in the forum will look at it.
Sep 26 '08 #2
lage
6
Without seeing any code I cannot be certain, but it looks like your .Net app is picking up the connection string from the COM component just fine. The error you are receiving is occuring in an attempt to resolve the connection string. Perhaps the syntax in the COM Component for the connection string needs to be modified for the .Net SqlConnection to parse it correctly. If you add some Debug.Write(connectionString) code to your .Net in the method where SqlConnection.Open is called, you can print out the ConnectionString it is trying to resolve. If the problem is not obvious, post the results of the Debug output and someone in the forum will look at it.
Thank you for your answer! I am pretty sure it's not the syntax. I pasted the same connection string “hard coded” into the VB6 code and it worked without problem. The database is connected only within the Com+ component in this test, but I will probably connect the database from the .Net application when I implement the new parts to the current system.
So it looks like it’s the application object that doesn’t appear when called from .Net.

In the VB6 Com+ component, the connection string is fetched by the following code:
Set objContext = GetObjectContext()
connstring = objContext.Item("Application")("connstring")

Any suggestions?

Lage
Sep 26 '08 #3
mldisibio
190 Expert 100+
To clarify, is it the old VB6 COM Component that is executing the call to GetObjectContext()? So the COM Component is getting the connection string and opening the database, not the .Net app?

You say the connection string is stored in global.asa? So is this an ASP application, hosting a COM+ component, that you are now trying to wrap or call to from ASP.Net?

So basically, this is still a legacy ASP app that is doing all the work and you are trying to get the data pumped out into a .Net process?

(Those were all questions, so please confirm...)

If so, I don't have enough experience with that mix to give a authoritative answer.

Nonetheless it still seems to me that the particular error you are receiving indicates a problem actually connecting to the database, and not a problem retrieving the connection string. I don't think you get such an explicit error if the connection string is null.

When trying to wrap components, sometimes the original entry point gets bypassed. For example, did the original application have a way to open the connection and keep it open? (Sometimes the COM component is hosted in Distributed Transaction Server which keep it alive) In the original application, there may have been a persistent connection, but now with the wrapper approach, the operations may be more atomic (Call COM component and open connection...Call COM component and execute query...but the connection closes between the two calls)

I am just hazarding guesses here, and I hope someone else with more experience will jump in.

In the meantime, I will give one other suggestion from a mile-high perspective: (This is strictly just an opinion.) I understand you may have requirements to transition using the legacy COM components and the requirements may be out of your control, but quite honestly, the time spent trying to get legacy custom COM components to work with newer ASP.Net applications, IMHO could be better spent converting the COM to a .Net class library. Honestly, the task/scope of a COM component is usually pretty specific and simply converting it to a .Net library is straightforward. Trying to get legacy COM in an ASP hosted process to talk to .Net in an ASP.Net hosted process often leads to much wrestling with the quirks of the underlying technology and loses focus on the business model and robust design.
Sep 26 '08 #4
lage
6
Thank you again for your answer. You were right about the connection string. There was an old exception retrieving an obsolete connection string while not calling the Com+ component from an asp-file.

I have got answer from a MS employee at MSDN now and I hope they will help me to sort this out.

http://social.msdn.microsoft.com/For...-41d98346562f/


Thanks for your help

Lage
Sep 29 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Mattt | last post by:
Hi, I've run into a rather odd problem. get Methods seem to return values from the wrong methods! For example, let's pretend my activex control stores values about a person. getName would return...
1
by: Hannes Grund | last post by:
Dear all, probably offtopic for the general python list, but I don't know were to go else. I'm currently developing somekind of middleware wich makes heavy use of pythonwin/com extensions....
0
by: Gary | last post by:
sorry for not cross-posting originally (originally posted in the components subgroup) I seem to have run into two documented bugs whose workarounds are incompatible. What I have is an OCX...
6
by: Eric Lilja | last post by:
Hello, I have a std::vector storing pointers to an abstract base class OptionBase. OptionBase is not templated but I am deriving a template class called Option from OptionBase. The class Option has...
2
by: Tony Liu | last post by:
Hi, I want to get the name of the calling function of an executing function, I use the StackTrace class to do this and it seems working. However, does anyone think that there any side effect...
6
by: Michael Vanhoutte | last post by:
We have an ASP.NET website written in C# that accesses a VB6 COM component. That component accesses the ASP-objects in the following manner: Set objContext = GetObjectContext Set objRequest =...
5
by: ross kerr | last post by:
Hi All, I am extending the combobox to create a control that selects an item based on the text the user is typing into the text area of the control. I have an issue that occurs only when i...
0
by: TMN | last post by:
I have an appplication that uses Enterprise Services components built with C#. The core app works fine, the components work as expected in COM+, etc. However, I now need to have one of the...
6
by: Wesley Peace | last post by:
I hate to cross post, but I've gotten no answer yet on a problem I'm having with visual studio 2008. I've created a series of forms with controls to access a Access database tables. The...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.