Good morning everyone. I am trying to develop a Web site with a search feature that will search a MS SQL database based on text entered into the "Last Name" text field of the search form. I have the search feature working somewhat however, there are some additional tasks which I need it to perform to produce better results. I have the results set to produce anything >= than the text input into the last name field. However, the current results only account for the first and second letter entered. For example if I input the last name of 'Fontenot' into the text box and click search anything starting with an 'Fo' and beyond will be displayed. This means that any name starting with a letter after F (such as G, H, I, etc....) will also be produced. If I set the results to simply = to the text input into the last name field then the only results which appear would be a last name with the exact text entered. Thus, if someone just entered the first few letters of a last name, nothing will show up in the results.
What I need is if I enter the letters 'Font' into the last name text field and then click submit, any last name beginning with 'Font' will show up (not any last name beginning with Fo, Fi, Fl, Fu,G, H, I, J, K, etc...). I have tried everything I can possibly think of to get my search to produce the required results with no luck. Does anyone have any ideas on how to get this to work? I also have a few other functions I would like this search to be able to handle but I need to get this main one resolved first. Any help would be greatly appreciated. Thank you for your time and assistance with this matter ahead of time.
Here is the code for my search form:
<form id="Quick_Search" runat="server" style="width: 220px">
<asp:TextBox id="F_Name_1" runat="server"></asp:TextBox>
<strong>First Name</strong><br />
<asp:TextBox id="L_Name_2" runat="server"></asp:TextBox>
<strong>Last Name<br />
</strong><br />
<asp:Button id="Button1" runat="server" Text="Begin Search" PostBackUrl="results2.aspx" BackColor="Silver" Font-Bold="True" />
</form>
Here is the code for my results form:
<form id="form1" runat="server">
<asp:GridView id="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" AllowSorting="True" AllowPaging="True">
<Columns>
<asp:commandfield ShowSelectButton="True">
</asp:commandfield>
<asp:boundfield DataField="F_Name" HeaderText="F_Name" SortExpression="F_Name">
</asp:boundfield>
<asp:boundfield DataField="M_Name" HeaderText="M_Name" SortExpression="M_Name">
</asp:boundfield>
<asp:boundfield DataField="L_Name" HeaderText="L_Name" SortExpression="L_Name">
</asp:boundfield>
<asp:boundfield DataField="Address" HeaderText="Address" SortExpression="Address">
</asp:boundfield>
<asp:boundfield DataField="City" HeaderText="City" SortExpression="City">
</asp:boundfield>
<asp:boundfield DataField="State" HeaderText="State" SortExpression="State">
</asp:boundfield>
<asp:boundfield DataField="Zip" HeaderText="Zip" SortExpression="Zip">
</asp:boundfield>
<asp:boundfield DataField="County" HeaderText="County" SortExpression="County">
</asp:boundfield>
</Columns>
<SelectedRowStyle BackColor="Silver" BorderColor="Black" BorderStyle="Solid" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:usernameConnectionString %>" SelectCommand="SELECT [F_Name], [M_Name], [L_Name], [Address], [City], [State], [Zip], [County], [TDF_Num], [Cert_Num], [Owner_Name], [Legal_Descrip] FROM [Lookup_Table] WHERE ([L_Name] >= @L_Name2) ORDER BY [L_Name], [F_Name]">
<SelectParameters>
<asp:formparameter FormField="L_Name_2" Name="L_Name" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</form>