Solved

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

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now