Hi,
I have the following procedure below:
I am getting 2 errors on compile:
Argument '2': cannot convert from 'System.Data.SqlClient.SqlDataReader' to
'ref System.Data.SqlClient.SqlDataReader'
Argument '3': cannot convert from 'System.Text.StringBuilder' to 'ref
System.Text.StringBuilder'
the PrintChildrenRecursive is a class in a referenced DLL that was written in
VB.NET.
this function takes a dataset and loops through it creating a javastring
using stringbuilder that creates a parent-child tree of html hyperlinks.
the printchildrecursive function accepts the Dr and Sbuilder ByReference.
private static void PrintFromRoot(SqlDataReader Dr, StringBuilder SBuilder)
{
PrintChildren PCR = new PrintChildren();
SBuilder.Append("[");
PCR.PrintChildrenRecursive(1, Dr, SBuilder, false);
SBuilder.Remove(1,2); //remove comma and bracket from beginning of string
SBuilder.Append("];");
}
I don't understand why conversion is occuring because they are already of
the correct type as already indicated by the error messages.
thanks
Chris 3 3415
Chris,
You are passing parameters by reference. In order to do so, you need to
use the ref keyword, like this:
obj.PrintFromRoot(ref sqlDataReader, ref stringBuilder);
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Chris" <Ch***@discussions.microsoft.com> wrote in message
news:79**********************************@microsof t.com... Hi,
I have the following procedure below: I am getting 2 errors on compile:
Argument '2': cannot convert from 'System.Data.SqlClient.SqlDataReader' to 'ref System.Data.SqlClient.SqlDataReader'
Argument '3': cannot convert from 'System.Text.StringBuilder' to 'ref System.Text.StringBuilder'
the PrintChildrenRecursive is a class in a referenced DLL that was written in VB.NET.
this function takes a dataset and loops through it creating a javastring using stringbuilder that creates a parent-child tree of html hyperlinks.
the printchildrecursive function accepts the Dr and Sbuilder ByReference.
private static void PrintFromRoot(SqlDataReader Dr, StringBuilder SBuilder) { PrintChildren PCR = new PrintChildren();
SBuilder.Append("["); PCR.PrintChildrenRecursive(1, Dr, SBuilder, false);
SBuilder.Remove(1,2); //remove comma and bracket from beginning of string
SBuilder.Append("];"); }
I don't understand why conversion is occuring because they are already of the correct type as already indicated by the error messages.
thanks
Chris
Nicholas,
thank you so much!
"Nicholas Paldino [.NET/C# MVP]" wrote: Chris,
You are passing parameters by reference. In order to do so, you need to use the ref keyword, like this:
obj.PrintFromRoot(ref sqlDataReader, ref stringBuilder);
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Chris" <Ch***@discussions.microsoft.com> wrote in message news:79**********************************@microsof t.com... Hi,
I have the following procedure below: I am getting 2 errors on compile:
Argument '2': cannot convert from 'System.Data.SqlClient.SqlDataReader' to 'ref System.Data.SqlClient.SqlDataReader'
Argument '3': cannot convert from 'System.Text.StringBuilder' to 'ref System.Text.StringBuilder'
the PrintChildrenRecursive is a class in a referenced DLL that was written in VB.NET.
this function takes a dataset and loops through it creating a javastring using stringbuilder that creates a parent-child tree of html hyperlinks.
the printchildrecursive function accepts the Dr and Sbuilder ByReference.
private static void PrintFromRoot(SqlDataReader Dr, StringBuilder SBuilder) { PrintChildren PCR = new PrintChildren();
SBuilder.Append("["); PCR.PrintChildrenRecursive(1, Dr, SBuilder, false);
SBuilder.Remove(1,2); //remove comma and bracket from beginning of string
SBuilder.Append("];"); }
I don't understand why conversion is occuring because they are already of the correct type as already indicated by the error messages.
thanks
Chris This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Christoph Boget |
last post by:
I am getting an error (a few among many) for the
following lines of code:
retval.BrokerName = (( curRow ==
System.DBNull.Value ) ? SqlString.Null : (string)curRow );
retval.BrokerGroupId = ((...
|
by: Andy Sutorius |
last post by:
Hi,
I am receiving the error when compiling the project, "cannot implicitly
convert type object to string".
The error points to this line of code and underlines the
dtrRecipient:...
|
by: Tim Cartwright |
last post by:
I have a page that has the login control on it, nothing else. This page inherits from a master page, neither page has any code in it. This page works perfectly when running on the WebDev debug web...
|
by: Christophe |
last post by:
class A {}
class B {}
interface MyInterface
{
void method(A a);
void method(B b);
}
|
by: groups |
last post by:
This is my first foray into writing a generic method and maybe I've
bitten off more than I can chew.
My intent is to have a generic method that accepts a value name and
that value will be...
| |
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,...
|
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...
|
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...
|
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...
|
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,...
|
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...
| |
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |