Solved

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

Posted on 2012-04-04
3
282 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 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
FInd Image Control Gridview 3 35
SSRS Deployment problem 5 91
looking for an ASP.net report designer 4 41
ASP.NET Built-In Report Creator / Viewer 5 20
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 …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

762 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