Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 289
  • Last Modified:

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

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
goodk
Asked:
goodk
  • 2
1 Solution
 
Lalit ChandraCommented:
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
 
goodkAuthor Commented:
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
 
Lalit ChandraCommented:
Thanks for your points.
0

Featured Post

Independent Software Vendors: 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!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now