Connection working in query builder but not on local host website


I am building a web site in using visual studio 2013 asp 4.0 C# sql server (not certain of version).

I am using an existing connect string that works for my other queries. I know that my query is generating a data set in the query builder however when i build and run in a browser i am not getting a result set. It as been suggested to me that it could be a problem with my connection string. Why would i be getting a result set in the query builder but not in the website when using the same search term?

This is my data source

<asp:SqlDataSource ID="SqlDataSourceSearch" runat="server" ConnectionString="<%$ ConnectionStrings:BazaarCeramicsConnectionString %>" 
    SelectCommand="SELECT Categories.Name, Products.ProductID, Products.Name AS Expr1 FROM Products INNER JOIN Categories ON Products.CategoryID = Categories.CategoryID WHERE (Products.Name LIKE '%' + @SearchQuery + '%')">
    <asp:QueryStringParameter Name="SearchQuery" QueryStringField="search" 
        Type="String" />

This is my data list

<asp:DataList ID="DataList1" runat="server" DataKeyField="ProductID" DataSourceID="SqlDataSourceSearch">
        <asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' />
        <br />
        <asp:Label ID="ProductIDLabel" runat="server" Text='<%# Eval("ProductID") %>' />
        <br />
        <asp:Label ID="Expr1Label" runat="server" Text='<%# Eval("Expr1") %>' />
        <br />

This is my input and i can see the query string being appended to the URL

<div class="searchBox">
<asp:TextBox ID="SearchTextBox" runat="server"></asp:TextBox>
<asp:Button ID="SearchButton" runat="server" onclick="Button1_Click" Text="Search" />
<a href="ShoppingCart.aspx"><img id="cartIcon" src="Images/shoppingCartIcon.png" /></a>

This is my code behind

protected void Button1_Click(object sender, EventArgs e)
    string SearchTerm = SearchTextBox.Text;
    Response.Redirect("SearchResults.aspx?SearchQuery=" + Server.UrlEncode(SearchTerm));

and finally this is my connection string

<add name="BazaarCeramicsConnectionString" connectionString="Data Source=CATHERINE\SQLEXPRESS;Initial Catalog=BazaarCeramics;User ID=****;Password=******"  providerName="System.Data.SqlClient" />

1 answer


Did you find a solution to this?

If you're not seeing any error running the code I don't think this would be connection string related.

It's more likely your code is wrong somehow. I'm not too familiar with webforms components though.