473,473 Members | 1,768 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Help with SELECT LIKE statement in Visual Web Developer

23 New Member
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
1 3618
MMcCarthy
14,534 Recognized Expert Moderator MVP
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

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

Similar topics

4
by: SD | last post by:
Hi, I'm running Windows XP and SQL Server Developer Edition (sp3) and I'm trying to install the MS SQL Server Reporting Services that is in the MSDN of April 2004. I also have Visual studio.net...
4
by: Terencetrent | last post by:
I having been using Access '97/2002 for about 4 years now and have never really had the need or the time to learn visual basic. Well, I think the time has finally come. I need help with Visual...
3
by: ssb | last post by:
Hello, This may be very elementary, but, need help because I am new to access programming. (1) Say, I have a column EMPLOYEE_NAME. How do I fetch (maybe, cursor ?) the values one by one and...
5
by: freddy | last post by:
I have a select statement like this: string Select = "Select TableofContents, DataOwner, Delegates From NYC"; and it work fine, but if I was to put a space in like this: string Select = "Select...
2
by: tjones | last post by:
Hi, I have installed VS2003 and have been wroting some c++ code. Mainly created a win32 console application for my c++ program. I have a few questions: 1. Is there a menu to...
1
by: Mike | last post by:
can some look at this select statement and tell me whats wrong with it/ I keep getting an error on the SELECT. dbCommand = New SqlDataAdapter("select EffectiveDate,RD as type" & _ "SELECT Case...
2
by: NathanV | last post by:
I need some help with a SQL statement (SQL Server 2k). I have three tables, an Artists table which holds user info, a Types table which holds the TypeID and Description for different types (I.e....
4
by: | last post by:
Environment: Microsoft Visual Studio 2005 Professional Edition Microsoft Visual Source Safe 2005 FxCop 1.32 Project: ASP.NET 2.0 C# Project 5 Developers We are trying to implement FxCop...
5
by: chris.withers | last post by:
Hi all, I'm attempting to do something like the following SQL query: SELECT * FROM `users` WHERE idusers != 3 | 2; such as: = "idusers <> 3OR 2";
8
by: gderosa | last post by:
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"...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.