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!
8 2466
Try this:
I didnt want the query to return just results that start with S, I want it to return results that start with the session parameter, Session("NAME"), I was just using the S as an example.
Try and hard code it with that to see if it works then worry about adding the session name.
Yup it works by hardcoding it like that but it brings me all results that have 's' in them wheras I want all results that start with 's' as an example. If all worked correctly I would like the results to start with the stored session variable, which it is not doing. It is returning results that include the session variable but not the ones that start with the session variable. I really appreciate ur help!
For example I currently have it like this:
WHERE ([last] LIKE '%' + ? + '%')">
Which is returning results that include the session variable, but I want to return results that start with the session variable and have tried all these variations below but none of them work:
WHERE ([last] LIKE '' + ? + '%')">
WHERE ([last] LIKE ? + '%')">
WHERE ([last] LIKE '?%')">
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!
What about
WHERE ([last] LIKE "& &")
If its text leteral (sp) add the ' ' around it.
or if it suppose to be text it would be WHERE ([last} LIKE '"& ? &"')
If the ? is a varaible it could be name or some other naming convention. Let me know if it works.
What about
WHERE ([last] LIKE "& &")
If its text leteral (sp) add the ' ' around it.
or if it suppose to be text it would be WHERE ([last} LIKE '"& ? &"')
If the ? is a varaible it could be name or some other naming convention. Let me know if it works.
I tried the LIKE '"& ? & "' and it still doesnt work, it says poorly formed expression. Thanks for your help though!
I tried the LIKE '"& ? & "' and it still doesnt work, it says poorly formed expression. Thanks for your help though!
wow I cant believe I got it to work all it needed was a space in place of the first %:
WHERE ([last] LIKE ' ' + ? + '%')
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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....
|
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...
|
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";
|
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"...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |