Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

getting a warning in asp.net while reading data using mssql

Posted on 2012-04-04
3
Medium Priority
?
287 Views
Last Modified: 2012-04-04
bool xNotField;

                                xNotField = reader.GetName(fcount) == "DATA_TYPE" && reader[fcount] == "timestamp";
                                xNotField = xNotField &  xID == reader[fcount] ;


warning CS0252: Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string'

 reader[fcount] == "timestamp";
0
Comment
Question by:goodk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
Lalit Chandra earned 2000 total points
ID: 37806762
you should typecast the things before comparision.

i.e   xNotField = reader.GetName(fcount).ToString() == "DATA_TYPE" && reader[fcount] .ToString() == "timestamp";



Microsoft Recomendation :
http://msdn.microsoft.com/en-us/library/f6dtw2ah(v=vs.80).aspx
0
 

Author Closing Comment

by:goodk
ID: 37806984
xRead = reader[fcount].ToString();
                                xNotField = reader.GetName(fcount) == "DATA_TYPE" ;
                                xNotField = xNotField & xRead == "timestamp";
                                xNotField = xNotField & xID == xRead;

I had to change it like above to make it work.
0
 
LVL 7

Expert Comment

by:Lalit Chandra
ID: 37807028
Thanks for your points.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

660 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question