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

Neha SharmaPosted May 30, 2013, 8:14 AM
Please elaborate more your problem like from where you want to compare and with whom?
anji marothuPosted May 30, 2013, 7:19 AM
Pankaj PandeyPosted May 30, 2013, 2:33 AM
mark as answered if it really helped.
thanx
anji marothuPosted May 30, 2013, 2:22 AM
Jay ParekhPosted May 30, 2013, 2:21 AM
string value=dr["value"].ToString();
if(value.Equals("valid", StringComparison.CurrentCultureIgnoreCase))
{
// statement
}
else
{
// statement
}
Pankaj PandeyPosted May 30, 2013, 2:04 AM
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.
Parveen SiwachPosted May 30, 2013, 2:01 AM
string value= Convert.ToString(dr["value"]).Trim().ToUpper();
if(value=="VALID")
{
// statement
}
else
{
// statement
}