By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,493 Members | 1,233 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,493 IT Pros & Developers. It's quick & easy.

Help with SELECT LIKE statement in Visual Web Developer

P: 23
I am trying to perform a query on an Access database using Visual Web Developer based on a session variable. Here is the whole tag:

<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/Residents.mdb"
SelectCommand="SELECT [last], [first], [unit], [urb] FROM [Residents] WHERE ([last] LIKE '%' + ? + '%')">

Now I only want the results to start with lets say 'S' for Smith or Smitty. I understand that there should be no wildcard operator before the session variable ? above. But if I change the code it results nothing as the search, I have tried these variations with no success:
WHERE ([last] LIKE '' + ? + '%')">
WHERE ([last] LIKE ? + '%')">
WHERE ([last] LIKE '?%')">

Visual Web Developer automatically puts the ? in place of the session variable, which BTW is called Session("NAME")

Can anyone please help with how to format the code so it would work? Thanks!
Nov 21 '06 #1
Share this Question
Share on Google+
1 Reply


MMcCarthy
Expert Mod 10K+
P: 14,534
The wildcard in Access is '*' the asterisk.

Access doesn't like to follow the pack. ;)


I am trying to perform a query on an Access database using Visual Web Developer based on a session variable. Here is the whole tag:

<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/Residents.mdb"
SelectCommand="SELECT [last], [first], [unit], [urb] FROM [Residents] WHERE ([last] LIKE '%' + ? + '%')">

Now I only want the results to start with lets say 'S' for Smith or Smitty. I understand that there should be no wildcard operator before the session variable ? above. But if I change the code it results nothing as the search, I have tried these variations with no success:
WHERE ([last] LIKE '' + ? + '%')">
WHERE ([last] LIKE ? + '%')">
WHERE ([last] LIKE '?%')">

Visual Web Developer automatically puts the ? in place of the session variable, which BTW is called Session("NAME")

Can anyone please help with how to format the code so it would work? Thanks!
Nov 21 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.