Jump to content
Sign in to follow this  
Wurn

ASP.NET text search box

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.

Share this post


Link to post
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>

Share this post


Link to post
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.

Share this post


Link to post
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>

Share this post


Link to post
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. :)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...