473,573 Members | 5,079 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

trouble getting ref object parameters while calling COM object with C#

I'm trying to call a COM object using C# but having no luck getting
values back for passed in ref objects.

I've tried the same call using VB.NET and can get data back. How would
I implement the following in C#

This is the method I am calling, which populates ref paramters with
results.

Sub Check_Customer( ByVal Customer As String, Optional ByRef oParam1 As
Object = Nothing, Optional ByRef oParam2 As Object = Nothing, Optional
ByRef oParam3 As Object = Nothing, Optional ByRef oParam4 As Object =
Nothing, Optional ByRef Return As Object = Nothing)

Here is the VB.net code, which calls the function passing

Dim customer = "123456", oParam1 = Nothing, oParam2 = Nothing, oParam3
= Nothing, oParam4 = Nothing, oReturnBlock = Nothing

comObject.Check _Customer(custo mer, oParam1, oParam2, oParam3, oParam4,
oReturnBlock)

Dim myDA As System.Data.Ole Db.OleDbDataAda pter = New
System.Data.Ole Db.OleDbDataAda pter
Dim myDS1 As DataSet = New DataSet
Dim myDS2 As DataSet = New DataSet
myDA.Fill(myDS1 , oParam1, "CustomerDetail s")
myDA.Fill(myDS2 , oParam2, "CustomerNotes" )
Any help would be greatly appreciated.

Oct 29 '07 #1
2 1878
string a=null,b=null;
aaaa(ref a, ref b);
u should use ref key world when passing parrameter to com function and
assing null before passing it.

"ro**********@g mail.com" wrote:
I'm trying to call a COM object using C# but having no luck getting
values back for passed in ref objects.

I've tried the same call using VB.NET and can get data back. How would
I implement the following in C#

This is the method I am calling, which populates ref paramters with
results.

Sub Check_Customer( ByVal Customer As String, Optional ByRef oParam1 As
Object = Nothing, Optional ByRef oParam2 As Object = Nothing, Optional
ByRef oParam3 As Object = Nothing, Optional ByRef oParam4 As Object =
Nothing, Optional ByRef Return As Object = Nothing)

Here is the VB.net code, which calls the function passing

Dim customer = "123456", oParam1 = Nothing, oParam2 = Nothing, oParam3
= Nothing, oParam4 = Nothing, oReturnBlock = Nothing

comObject.Check _Customer(custo mer, oParam1, oParam2, oParam3, oParam4,
oReturnBlock)

Dim myDA As System.Data.Ole Db.OleDbDataAda pter = New
System.Data.Ole Db.OleDbDataAda pter
Dim myDS1 As DataSet = New DataSet
Dim myDS2 As DataSet = New DataSet
myDA.Fill(myDS1 , oParam1, "CustomerDetail s")
myDA.Fill(myDS2 , oParam2, "CustomerNotes" )
Any help would be greatly appreciated.

Oct 29 '07 #2
On Oct 29, 1:38 am, Som Nath Shukla
<SomNathShu...@ discussions.mic rosoft.comwrote :
string a=null,b=null;
aaaa(ref a, ref b);
u should use ref key world when passing parrameter to com function and
assing null before passing it.

"rocketfir...@g mail.com" wrote:
I'm trying to call a COM object using C# but having no luck getting
values back for passed in ref objects.
I've tried the same call using VB.NET and can get data back. How would
I implement the following in C#
This is the method I am calling, which populates ref paramters with
results.
Sub Check_Customer( ByVal Customer As String, Optional ByRef oParam1 As
Object = Nothing, Optional ByRef oParam2 As Object = Nothing, Optional
ByRef oParam3 As Object = Nothing, Optional ByRef oParam4 As Object =
Nothing, Optional ByRef Return As Object = Nothing)
Here is the VB.net code, which calls the function passing
Dim customer = "123456", oParam1 = Nothing, oParam2 = Nothing, oParam3
= Nothing, oParam4 = Nothing, oReturnBlock = Nothing
comObject.Check _Customer(custo mer, oParam1, oParam2, oParam3, oParam4,
oReturnBlock)
Dim myDA As System.Data.Ole Db.OleDbDataAda pter = New
System.Data.Ole Db.OleDbDataAda pter
Dim myDS1 As DataSet = New DataSet
Dim myDS2 As DataSet = New DataSet
myDA.Fill(myDS1 , oParam1, "CustomerDetail s")
myDA.Fill(myDS2 , oParam2, "CustomerNotes" )
Any help would be greatly appreciated.
There is no problem getting string values passed by reference, the
problem is with parameters of type Object passed by reference. The COM
component returns recordsets in the ref objects and vb.net handles
this automatically so values can be accessed eg. oParam1("Name") after
the call contains data or even filling a dataset. However with C# I
can't get to the data within the Object.

I have tried the InvokeMember call using the BindingFlags.Ge tProperty
and BindingFlags.Ge tField but still unable to get the recordset.

Oct 29 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
8062
by: Martin Raychev | last post by:
Hi all, I have the following problem: I have a private method that returns a SqlDataReader. For this to work I have not to close the DB connection in the above method. I do this only to
1
4980
by: Paul D. Fox | last post by:
I'm trying to launch a Child Window from a hyperlink on a Datagrid and have it recieve multiple values from the Parent Window. Upon recieving the values in the Child Window, I need to access them in the code-behind so I can render a datagrid in the Child. I've tried just doing another Postback in the child's onLoad event but I get a...
10
1926
by: Peter Afonin | last post by:
Hello, I have a simple client-side form that is checking the domain availability on the domain registrar's server: <FORM action="https://www.webnames.ru/scripts/RegTimeSRS.pl" method="post"> <input type="hidden" name="thisPage" value="pispCheckDomain"> <input type="hidden" name="username" value="test"> <input type="hidden"...
12
8680
by: Jim Hammond | last post by:
I am passing the whole object instead or parameters in my select and update methods. I can get the updated object if I set UpdateMethod, let ASP.NET autogenerate an update button, and then press update after making changes, but I don't want that update button. How can I get the updated object when the user presses one of my other action...
2
1499
by: somersbar | last post by:
im trying to get a table from a microsoft access database on a simple web form using visual basic.net. ive set up the database as a file dsn. this is my connection string: DBQ=C:\Program Files\Microsoft Office\OFFICE11\SAMPLES\Northwind.mdb;DefaultDir=C:\Program Files\Microsoft Office\OFFICE11\SAMPLES;Driver={Microsoft Access Driver...
5
1429
by: mlg1906 | last post by:
I'm developing an intranet site in ASP.NET 2.0 but I can't seem to connect to the DB from within my code. I've created a .vb class that houses a private Connection() that other functions within the class can call to connect to the database. In the calling function, I've declared my connection object and called the "Open" method on the object....
48
4434
by: Alex Chudnovsky | last post by:
I have come across with what appears to be a significant performance bug in ..NET 2.0 ArrayList.Sort method when compared with Array.Sort on the same data. Same data on the same CPU gets sorted a lot faster with both methods using .NET 1.1, that's why I am pretty sure its a (rather serious) bug. Below you can find C# test case that should...
0
1989
by: aboutjav.com | last post by:
Hi, I need some help. I am getting this error after I complete the asp.net register control and click on the continue button. It crashed when it tries to get it calls this Profile property ((string)(this.GetPropertyValue("Address1")));
2
2439
by: gradinafrica | last post by:
I'm trying to create a log out button that uses AJAX to call a php file which ends the current session: //logout.php <?php if (!session_start()); session_destroy(); //Destroys the session echo "success"; ?>
0
7792
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7709
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8039
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. ...
1
7800
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...
0
8091
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...
0
6435
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...
0
3738
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...
1
2228
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
1
1330
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.