Wurn Posted October 29, 2010 Share Posted October 29, 2010 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 More sharing options...
aspnetguy Posted October 29, 2010 Share Posted October 29, 2010 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 More sharing options...
Wurn Posted October 29, 2010 Author Share Posted October 29, 2010 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 More sharing options...
Wurn Posted October 29, 2010 Author Share Posted October 29, 2010 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 More sharing options...
Wurn Posted November 2, 2010 Author Share Posted November 2, 2010 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.