Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Cannot convert to Ref parameter from C# to VB.Net

Reply
Thread Tools

Cannot convert to Ref parameter from C# to VB.Net

 
 
Sanjay Tibrewal
Guest
Posts: n/a
 
      08-04-2004
Hello there,

I have some code in a VB library dll whose signature is as

// VB private library code
Public Sub ExecuteNonQuery(ByVal sConn As String, _
ByRef oCmd As SqlClient.SqlCommand)

I create another project in C# and include the library locally. I use the
following code to
call the function in VB library

// C# code
string m_sConn;
SqlCommand oCmd2 = new SqlCommand();
m_oDac.ExecuteNonQuery(m_sConn, oCmd2);

When I compile the above code I get the following error. Why can't an object
passed in to the function in C# be converted to a ref object in VB.Net dll?

C:\Office\Test\WebDAVTest\Class1.cs(516): Argument '2': cannot convert from
'System.Data.SqlClient.SqlCommand' to 'ref System.Data.SqlClient.SqlCommand'

Thanks for your help.

Sanjay.


 
Reply With Quote
 
 
 
 
Kevin Spencer
Guest
Posts: n/a
 
      08-04-2004
Try

m_oDac.ExecuteNonQuery(m_sConn, ref oCmd2)

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Sanjay Tibrewal" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello there,
>
> I have some code in a VB library dll whose signature is as
>
> // VB private library code
> Public Sub ExecuteNonQuery(ByVal sConn As String, _
> ByRef oCmd As SqlClient.SqlCommand)
>
> I create another project in C# and include the library locally. I use the
> following code to
> call the function in VB library
>
> // C# code
> string m_sConn;
> SqlCommand oCmd2 = new SqlCommand();
> m_oDac.ExecuteNonQuery(m_sConn, oCmd2);
>
> When I compile the above code I get the following error. Why can't an

object
> passed in to the function in C# be converted to a ref object in VB.Net

dll?
>
> C:\Office\Test\WebDAVTest\Class1.cs(516): Argument '2': cannot convert

from
> 'System.Data.SqlClient.SqlCommand' to 'ref

System.Data.SqlClient.SqlCommand'
>
> Thanks for your help.
>
> Sanjay.
>
>



 
Reply With Quote
 
 
 
 
Tom Dacon
Guest
Posts: n/a
 
      08-04-2004
You need to supply the 'ref' keyword in the calling code, as well as in the
called method's signature. So use:

m_oDac.ExecuteNonQuery(m_sConn, ref oCmd2);

Tom Dacon
Dacon Software Consulting

"Sanjay Tibrewal" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello there,
>
> I have some code in a VB library dll whose signature is as
>
> // VB private library code
> Public Sub ExecuteNonQuery(ByVal sConn As String, _
> ByRef oCmd As SqlClient.SqlCommand)
>
> I create another project in C# and include the library locally. I use the
> following code to
> call the function in VB library
>
> // C# code
> string m_sConn;
> SqlCommand oCmd2 = new SqlCommand();
> m_oDac.ExecuteNonQuery(m_sConn, oCmd2);
>
> When I compile the above code I get the following error. Why can't an

object
> passed in to the function in C# be converted to a ref object in VB.Net

dll?
>
> C:\Office\Test\WebDAVTest\Class1.cs(516): Argument '2': cannot convert

from
> 'System.Data.SqlClient.SqlCommand' to 'ref

System.Data.SqlClient.SqlCommand'
>
> Thanks for your help.
>
> Sanjay.
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Giving an rvalue ref to a function taking an rvalue ref Juha Nieminen C++ 13 08-29-2012 09:25 PM
passing ref to ptr again as ref to ptr.... osama178@gmail.com C++ 22 04-30-2008 10:42 AM
passing ref to ptr again as ref to ptr.... osama178@gmail.com C++ 6 04-29-2008 08:09 AM
passing ref to ptr again as ref to ptr.... osama178@gmail.com C++ 0 04-24-2008 08:23 PM
strong ref from weak ref? Navindra Umanee Ruby 2 02-12-2005 05:06 PM



Advertisments