Into below statement of SQL it was working fine until i added new condition which is: " AND AD.[approvAds]= 'Y' " its not showing the ads which has " Y " value where it should show it!? and there are ads which has value " Y " into column approvAds
Please note: some of ads such i explan about above dosent have UID and some has , but the statments suppose to show all with 3 conditions 1- country equal cookie 2- From table ads column approvAds should has value = Y 3- From UserInfo table column approv should have value= Y
so how i can update this statement to meets 4 conditions below and work fine
1- country equal cookie
2- From table ads column approvAds should has value = Y
3- From UserInfo table column approv should have value= Y
4- Show all ads not only those which has UID
if (!IsPostBack)
{
if (cookie["Location"] == null)
{
using (SqlConnection shwadsoneLogo = new SqlConnection(cs))
{
shwadsoneLogo.Open();
SqlDataAdapter dashowadsoneLogo = new SqlDataAdapter(@"
SELECT AD.[AdsID]
,AD.[UID]
,AD.[Section]
,AD.[Category]
,AD.[Country]
,AD.[State]
,AD.[City]
,SUBSTRING([AdsTit],1,30)+'...' as AdsTit
,SUBSTRING([AdsDesc],1,85) as AdsDesc
,AD.[AdsPrice]
,AD.[Img1]
,AD.[Currency]
,AD.[Section]
,AD.[Currency]
,AD.[AdsDate]
,AD.[approvAds]
,UI.[approv]
FROM [ads] as AD JOIN UserInfo as UI ON AD.[UID] = UI.[UID] where AD.[Country] = @Location AND AD.[approvAds]= 'Y' AND UI.[approv]='Y' ORDER BY [AdsDate] DESC", cs);
var location = cookie.Value;
dashowadsoneLogo.SelectCommand.Parameters.AddWithValue("@Location", location);
DataSet dsadsshowoneLogo = new DataSet();
dashowadsoneLogo.Fill(dsadsshowoneLogo);
homepageadsshow.DataSource = dsadsshowoneLogo.Tables[0];
homepageadsshow.DataBind();
}
}
else
{
// Your Session key could not be found, consider displaying an error
}
}