473,811 Members | 2,970 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GetObjectContex t problems when calling COM+ components from .NET

6 New Member
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="Microso ft 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 2669
mldisibio
190 Recognized Expert New Member
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(con nectionString) code to your .Net in the method where SqlConnection.O pen is called, you can print out the ConnectionStrin g 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 New Member
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(con nectionString) code to your .Net in the method where SqlConnection.O pen is called, you can print out the ConnectionStrin g 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 = GetObjectContex t()
connstring = objContext.Item ("Application") ("connstring ")

Any suggestions?

Lage
Sep 26 '08 #3
mldisibio
190 Recognized Expert New Member
To clarify, is it the old VB6 COM Component that is executing the call to GetObjectContex t()? 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...Ca ll 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 New Member
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
2230
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 their age, while getAge might return null! Something is also going wrong with my method that accepts input and returns a value (okay, it is a money conversion program!)... it is returning null! They are consistently returning the same, wrong...
1
2080
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. (The complete setup is: win2000/winXP, python2.2, win32all-152, wxPython resp. wxWindows). The software is aimed to manage data held by a software
0
3587
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 written in VB 6 that has a few classes in it. Many of the methods of the OCX are used by ASP, and so far have worked fine. I recently added a COM object reference to the DLL which consists of an SMTP client dll that is wrapped up in dual interface...
6
1587
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 a public member function called get_value() that is not present in the class OptionBase. My problem is that when calling get_value() I have to cast to Option<some_type>* and I was wondering if I can somehow remove the cast so I dont have to...
2
9786
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 towards this approach such as how would it works in multi-thread. Thanks Tony
6
4680
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 = objContext("Request") strAddress = objRequest.ServerVariables("REMOTE_ADDR") Set objContext = Nothing Set objRequest = Nothing On all the pages of our website the ASPCompAt-property is
5
2155
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 drop down the combo box as the users typing. When the on leave event is fired the value in the selected
0
945
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 components call out to a Web Service. I've added a Web Reference to the component (which I think is part of the problem - the reference is added to a newly created app.config file which I don't think COM+ components use) After adding the reference and...
6
2426
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 connection string works fine and the tables are added to the project without a problem. When I create the tables they appear to bind and I am able to preview the data in the database in design mode; however, at runtime no data is displayed and the...
0
10652
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10408
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10137
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9211
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7673
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5561
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5700
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4346
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3874
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.