Help with SQLDataSource query
Posted on 2014-03-02
Hello I have a search page that searches users profiles based on their City of Residence. This data table is called User Profiles.
I have another Table called locations and in that table the user has entered other locations of residence. This table includes the Columns Id, UserId, City,
Currently the search button queries only the users and retrieves from the UserProfiles table. I want to be able to query from both tables and show results on the DataList.
I am not sure how to set up the SQL datasource to query users from both tables and show results on one Datalist.
The code behind on the submit button is:
Protected Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Here is the current SQL Datasource which queries users in the UserProfiles Table:
<asp:SqlDataSource ID="SqlDataSource3" runat="server"
ConnectionString="<%$ ConnectionStrings:dbMyCMSConnectionString %>"
SelectCommand="SELECT UserId, UserName, FirstName, tagline, cookingstyle, cookingexperience, howmuchmoney, minimumhours, workdistance, contactnumber, email, howmany, groups, languages, City, State, Country, LastName, webaddress, Image_Path, timestamp, ipAddress, facebook, twitter, emailpersonal, website, linkedin, zip FROM UserProfiles WHERE (City LIKE '%' + @City + '%')">
<asp:ControlParameter ControlID="city" Name="City" PropertyName="Text" Type="String" />