Solved

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

Posted on 2012-04-04
3
281 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
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
Lalit Chandra earned 500 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

825 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