473,468 Members | 1,352 Online
Bytes | Software Development & Data Engineering Community
Create 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(customer, oParam1, oParam2, oParam3, oParam4,
oReturnBlock)

Dim myDA As System.Data.OleDb.OleDbDataAdapter = New
System.Data.OleDb.OleDbDataAdapter
Dim myDS1 As DataSet = New DataSet
Dim myDS2 As DataSet = New DataSet
myDA.Fill(myDS1, oParam1, "CustomerDetails")
myDA.Fill(myDS2, oParam2, "CustomerNotes")
Any help would be greatly appreciated.

Oct 29 '07 #1
2 1868
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**********@gmail.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(customer, oParam1, oParam2, oParam3, oParam4,
oReturnBlock)

Dim myDA As System.Data.OleDb.OleDbDataAdapter = New
System.Data.OleDb.OleDbDataAdapter
Dim myDS1 As DataSet = New DataSet
Dim myDS2 As DataSet = New DataSet
myDA.Fill(myDS1, oParam1, "CustomerDetails")
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.microsoft.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...@gmail.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(customer, oParam1, oParam2, oParam3, oParam4,
oReturnBlock)
Dim myDA As System.Data.OleDb.OleDbDataAdapter = New
System.Data.OleDb.OleDbDataAdapter
Dim myDS1 As DataSet = New DataSet
Dim myDS2 As DataSet = New DataSet
myDA.Fill(myDS1, oParam1, "CustomerDetails")
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.GetProperty
and BindingFlags.GetField 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
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
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...
10
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">...
12
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...
2
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...
5
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...
48
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...
0
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 ...
2
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...
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
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...
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...
1
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...
0
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,...
1
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...
0
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...
0
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 ...

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.