hi i was compare database value with string value but not working
here is a code
string value=dr["value"].ToString();
if(value=="valid")
{
// statement
}
else
{
// statement
}
here database value also valid
but the code jump to else part...
need solution.. thank you.
Loading


Parveen SiwachRank #6,758 · 257 reputationPosted May 29, 2013, 10:01 PM EDT
string value= Convert.ToString(dr["value"]).Trim().ToUpper();
if(value=="VALID")
{
// statement
}
else
{
// statement
}
Pankaj PandeyRank #642 · 3.7K reputationPosted May 29, 2013, 10:04 PM EDT
try this,
dr.Read();
string value=dr[0]["value"].ToString();
if(value=="valid")
{
// statement
}
else
{
// statement
}
if it works then mark as answered if not then please share youw query and row resulted from database.
Jay ParekhRank #1,395 · 1.2K reputationPosted May 29, 2013, 10:21 PM EDT
string value=dr["value"].ToString();
if(value.Equals("valid", StringComparison.CurrentCultureIgnoreCase))
{
// statement
}
else
{
// statement
}
anji marothu43 reputationPosted May 29, 2013, 10:22 PM EDT
Pankaj PandeyRank #642 · 3.7K reputationPosted May 29, 2013, 10:33 PM EDT
mark as answered if it really helped.
thanx
anji marothu43 reputationPosted May 30, 2013, 3:19 AM EDT
Neha SharmaRank #569 · 4.3K reputationPosted May 30, 2013, 4:14 AM EDT
Please elaborate more your problem like from where you want to compare and with whom?