I have a database with two columns: Retailers or Traders. A row can have only one of them with values while the other must be 'Null'. Both are nvarchars kinds. What I am trying to do is to show data if a radio button is selected for either Retailer or Trader. So I constructed a SelectCommand statement which is getting column names of either 'Retailers' or 'Traders' as a parameter but the SelectCommand statement still returns all records. What can I do? Thanks!
<asp:SqlDataSource ID="dsSearchResults" runat="server" ConnectionString="<%$ ConnectionStrings:AdoFabricsConnection %>"
SelectCommand="SELECT Name,Address1,City,State,Zip, Telephone, Email_Address, TO_THE_Trade, Retailer, Latitude, Longitude, SQRT(POWER([Latitude] - @Latitude, 2) + POWER([Longitude] - @Longitude, 2)) * 62.1371192 AS DistanceFromAddress FROM [ado_DealerLocator] WHERE (@RetTradColumnName IS NOT NULL) AND (ABS([Latitude] - @Latitude) < @LatLongUnitsParam) AND (ABS([Longitude] - @Longitude) < @LatLongUnitsParam) ORDER BY DistanceFromAddress">
<SelectParameters>
<asp:Parameter Name="Latitude" />
<asp:Parameter Name="Longitude" />
<asp:Parameter Name="LatLongUnitsParam" />
<asp:Parameter Name="RetTradColumnName" />
开发者_C百科 </SelectParameters>
</asp:SqlDataSource>
Never mind. I ended up combining the values of Traders and Retailers values into one new database field 'RetailerOrTrader' and programmed accordingly. Thanks.
精彩评论