I am getting an error (a few among many) for the
following lines of code:
retval[curRowNum].BrokerName = (( curRow["BrokerName "] ==
System.DBNull.V alue ) ? SqlString.Null : (string)curRow["BrokerName "] );
retval[curRowNum].BrokerGroupId = (( curRow["BrokerGrou pId"] ==
System.DBNull.V alue ) ? SqlInt32.Null : (int)curRow["BrokerGrou pId"] );
The errors are (in turn):
"Cannot implicitly convert type 'System.Data.Sq lTypes.SqlStrin g' to
'string'"
"Cannot implicitly convert type 'System.Data.Sq lTypes.SqlInt32 ' to 'int'"
So I'm curious, where is it getting the idea that I am
*implicitly* tyring to convert the type? When it is very
apparent that I am *explicitly* trying to convert it. I've
done some searches on Google but couldn't come up
with an appropriate answer. I'm hoping you'll be able
to tell me what's going on.
thnx,
Christoph 22 27892
Christopher,
What are the defined data types of BrokerName and BrokerId?
Telmo Sampaio
"Christoph Boget" <jc*****@yahoo. com> wrote in message
news:eb******** ******@TK2MSFTN GP09.phx.gbl... I am getting an error (a few among many) for the following lines of code:
retval[curRowNum].BrokerName = (( curRow["BrokerName "] == System.DBNull.V alue ) ? SqlString.Null : (string)curRow["BrokerName "] );
retval[curRowNum].BrokerGroupId = (( curRow["BrokerGrou pId"] == System.DBNull.V alue ) ? SqlInt32.Null : (int)curRow["BrokerGrou pId"] );
The errors are (in turn):
"Cannot implicitly convert type 'System.Data.Sq lTypes.SqlStrin g' to 'string'" "Cannot implicitly convert type 'System.Data.Sq lTypes.SqlInt32 ' to 'int'"
So I'm curious, where is it getting the idea that I am *implicitly* tyring to convert the type? When it is very apparent that I am *explicitly* trying to convert it. I've done some searches on Google but couldn't come up with an appropriate answer. I'm hoping you'll be able to tell me what's going on.
thnx, Christoph
Christoph Boget <jc*****@yahoo. com> wrote: I am getting an error (a few among many) for the following lines of code:
retval[curRowNum].BrokerName = (( curRow["BrokerName "] == System.DBNull.V alue ) ? SqlString.Null : (string)curRow["BrokerName "] );
retval[curRowNum].BrokerGroupId = (( curRow["BrokerGrou pId"] == System.DBNull.V alue ) ? SqlInt32.Null : (int)curRow["BrokerGrou pId"] );
The errors are (in turn):
"Cannot implicitly convert type 'System.Data.Sq lTypes.SqlStrin g' to 'string'" "Cannot implicitly convert type 'System.Data.Sq lTypes.SqlInt32 ' to 'int'"
So I'm curious, where is it getting the idea that I am *implicitly* tyring to convert the type? When it is very apparent that I am *explicitly* trying to convert it. I've done some searches on Google but couldn't come up with an appropriate answer. I'm hoping you'll be able to tell me what's going on.
I suspect that BrokerName is a string property - in which case, if the
condition is true, it's as if you're saying:
retval[curRowNum].BrokerName = SqlString.Null;
The only things you're *explicitly* converting are from object (as far
as the compiler knows) to string/int.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
> What are the defined data types of BrokerName and BrokerId?
'string' and 'int', respecitvely.
Christoph
> I suspect that BrokerName is a string property
It is. - in which case, if the condition is true, it's as if you're saying: retval[curRowNum].BrokerName = SqlString.Null;
I didn't think there would be an issue with setting a string property
to null. Or any data type to null. Is that not the case?
The only things you're *explicitly* converting are from object (as far as the compiler knows) to string/int.
And 'String.Null' is an object? Not a data type?
thnx,
Christoph
Christoph Boget <jc*****@yahoo. com> wrote: I suspect that BrokerName is a string property
It is.
- in which case, if the condition is true, it's as if you're saying: retval[curRowNum].BrokerName = SqlString.Null;
I didn't think there would be an issue with setting a string property to null. Or any data type to null. Is that not the case?
SqlString.Null is of type SqlString, not string, and it's not the same
as a null reference. The only things you're *explicitly* converting are from object (as far as the compiler knows) to string/int.
And 'String.Null' is an object? Not a data type?
SqlString.Null is a reference to a particular instance of SqlString.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
> The only things you're *explicitly* converting are from object (as far as the compiler knows) to string/int.
I've tried changing the code to this:
_brokerGroupId = toReturn.Rows[0]["BrokerGrou pId"] == System.DBNull.V alue ?
null : (int)toReturn.R ows[0]["BrokerGrou pId"];
so it's not converting from an object (presumably SqlInt32.Null?) but now
I'm getting the error:
"Type of conditional expression can't be determined because there is no
implicit
conversion between '<null>' and 'int'"
I just am not understanding this. Why is there an issue setting a data type
to
null? There shouldn't be one...
thnx,
Christoph
Hi,
In addition to Jon comments you also have the problem that the terniary
operator return a different type in the true and false statement, this is
not valid and you have to solve it. Maybe that is the "implicitin ess"
It's an error any way :)
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com... Christoph Boget <jc*****@yahoo. com> wrote: I am getting an error (a few among many) for the following lines of code:
retval[curRowNum].BrokerName = (( curRow["BrokerName "] == System.DBNull.V alue ) ? SqlString.Null : (string)curRow["BrokerName "] );
retval[curRowNum].BrokerGroupId = (( curRow["BrokerGrou pId"] == System.DBNull.V alue ) ? SqlInt32.Null : (int)curRow["BrokerGrou pId"] );
The errors are (in turn):
"Cannot implicitly convert type 'System.Data.Sq lTypes.SqlStrin g' to 'string'" "Cannot implicitly convert type 'System.Data.Sq lTypes.SqlInt32 ' to
'int'" So I'm curious, where is it getting the idea that I am *implicitly* tyring to convert the type? When it is very apparent that I am *explicitly* trying to convert it. I've done some searches on Google but couldn't come up with an appropriate answer. I'm hoping you'll be able to tell me what's going on.
I suspect that BrokerName is a string property - in which case, if the condition is true, it's as if you're saying:
retval[curRowNum].BrokerName = SqlString.Null;
The only things you're *explicitly* converting are from object (as far as the compiler knows) to string/int.
-- Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
so... that answer your question...
"Christoph Boget" <jc*****@yahoo. com> wrote in message
news:u7******** ******@TK2MSFTN GP11.phx.gbl... What are the defined data types of BrokerName and BrokerId?
'string' and 'int', respecitvely.
Christoph
Try this...
_brokerGroupId = (!toReturn.Rows[0].IsNull("Broker GroupId") ?
(int)toReturn.R ows[0]["BrokerGrou pId"] : -1);
There is no implicit conversion between null and int.
HTH,
Kyril
"Christoph Boget" <jc*****@yahoo. com> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. .. The only things you're *explicitly* converting are from object (as far as the compiler knows) to string/int.
I've tried changing the code to this:
_brokerGroupId = toReturn.Rows[0]["BrokerGrou pId"] == System.DBNull.V alue ? null : (int)toReturn.R ows[0]["BrokerGrou pId"];
so it's not converting from an object (presumably SqlInt32.Null?) but now I'm getting the error:
"Type of conditional expression can't be determined because there is no implicit conversion between '<null>' and 'int'"
I just am not understanding this. Why is there an issue setting a data type to null? There shouldn't be one...
thnx, Christoph
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Terminal882003 |
last post by:
Hi,
Here I have a question about MSCommLib. I need to dynamically add
activeX controls that requires run-time license for MSCommLib. The
following is the actual code:
AxMSCommLib.AxMSComm mscomm = new AxMSCommLib.AxMSComm();
string strLicense = "gfjmrfkfifkmkfffrlmmgmhmnlulkmfmqkqj";
|
by: Anita C |
last post by:
I have the foll. code to update the value of an attribute:
xmlDocument.Load("abc.xml");
XmlAttribute xmlAttrib = xmlDocument.SelectSingleNode(root/web/theme/@desc);
xmlAttrib.Value = ddDes.SelectedItem.ToString();
xmlDocument.Save("abc.xml");
However, I get the foll. error:
Cannot implicitly convert type 'System.Xml.XmlNode' to
'System.Xml.XmlAttribute'
|
by: Svyatoslav |
last post by:
Hi,
I have a problem with XmlNodes and my stack.
It looks something like this:
//declarations
XmlNode node, new_node;
Stack MyStack = new Stack();
//code
MyStack.Push(node);
|
by: juli |
last post by:
I declared:
public delegate void PaintEventHandler(object objSender,PaintEventArgs
pea);
and
this.Paint+=new PaintEventHandler(MyPaintHandler);
and the:
static void MyPaintHandler(object objSender,PaintEventArgs pea)
{
}
|
by: Jeff |
last post by:
I get the following error:
Cannot implicitly convert type 'Factory.Stack.pArrayStack' to
'Factory.Stack.StackDefs.ImStack'
at compile time.
I thought perhaps there was a mismatch between the interface method
types and the actual implementation types, so I removed all methods
from both the interface and the implementation (pArrayStack ) but
still get the error. Here is the code with just one simple method
still declared and implemented.
| |
by: Patrick Olurotimi Ige |
last post by:
When i convert:- this code from VB to C#
Why do i get error "Cannot implicitly convert type 'object' to 'bool'
VB
---
If cmdcommand.Parameters("ReturnValue").Value = 1 Then
lblStatus.Text = "Username already exists!"
Else
lblStatus.Text = "Success!"
|
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: objMailMessage.To = dtrRecipient;
I'm not sure why I am getting this error. Below is the complete code I am
working with.
|
by: Patrick Olurotimi Ige |
last post by:
compiling the code below i get the error:-
Cannot implicitly convert type 'object'to 'System.Xml.XmlDocument'
I'm getting the error on this line:-
myXml.Document = getXML("http://www.crn.com.au/rss.aspx?SCID=9");
Any ideas?
|
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 returned from the source. My first attempt was as
follows; (please ignore that error handling is not present in this
example)
public T GetValue<T(string objName) {
T results;
|
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...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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,...
|
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...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |