Jump to content

ASP.NET text search box


Wurn

Recommended Posts

Hi all, how do i go about getting a user that type in a persons contact name from the MS Access telephone db and/or by only typing in a persons first 2 or 3 letters of their name? My coding knowledge is lacking just so you guys know.MY current code which if you type in eg. "P" it displays every name that has a character "P" in which is not what I want.

			<asp:AccessDataSource ID="AccessDataSource1" runat="server" 				DataFile="~/Database/phone.mdb" 				SelectCommand="SELECT [FirstName], [LastName], [ext], [cell] FROM [table] WHERE ([FirstName] LIKE '%' + TextBox1 + '%')">				<SelectParameters>					<asp:ControlParameter ControlID="TextBox1" Name="FirstName" PropertyName="Text" 						Type="String" />				</SelectParameters>			</asp:AccessDataSource>

Any help or link to tutorial appreciated.

Link to comment
Share on other sites

If you do the follow it will get the records of people who's first name starts with P

			<asp:AccessDataSource ID="AccessDataSource1" runat="server"				DataFile="~/Database/phone.mdb"				SelectCommand="SELECT [FirstName], [LastName], [ext], [cell] FROM [table] WHERE ([FirstName] LIKE @fname + '%')">				<SelectParameters>					<asp:ControlParameter ControlID="TextBox1" Name="fname" PropertyName="Text"						Type="String" />				</SelectParameters>			</asp:AccessDataSource>

Link to comment
Share on other sites

Thank you, I will see if I can get it working.Also any good tutorials you know of where I can lookup on how to use a List/Menu that pulls data from my database and displays the info on my page? Been googling but nothing that helps so far yet.

Link to comment
Share on other sites

OK man it worked beautifully. Thx once again.If I may, impose some more. How would I then get it to display also if someone should type in a persons full name and surname or surname only? I have tried the "OR" / "AND" statements but no luck. :)

If you do the follow it will get the records of people who's first name starts with P
			<asp:AccessDataSource ID="AccessDataSource1" runat="server"				DataFile="~/Database/phone.mdb"				SelectCommand="SELECT [FirstName], [LastName], [ext], [cell] FROM [table] WHERE ([FirstName] LIKE @fname + '%')">				<SelectParameters>					<asp:ControlParameter ControlID="TextBox1" Name="fname" PropertyName="Text"						Type="String" />				</SelectParameters>			</asp:AccessDataSource>

Link to comment
Share on other sites

Any ideas for my question below? Thx

OK man it worked beautifully. Thx once again.If I may, impose some more. How would I then get it to display also if someone should type in a persons full name and surname or surname only? I have tried the "OR" / "AND" statements but no luck. :)
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...