19d30 ASP and Access, problem with LIKE statement
Sign Up |  Live StatsLive Stats    Articles 37,330| Comments 177,232| Members 19,409, Newest tanu sandhu| Online 489
Home Contact
 (Forgotten?): 
    Sikhism
    For best SPN experience, use Firefox Internet Browser!


                                                                   Your Banner Here!    




Click Here to Register/Sign Up Daily Hukamnama Member Blogs Downloads Website Navigation Help Fonts Tags
Sikh Philosophy Network » Sikh Philosophy Network » Current News » Information Technology » ASP and Access, problem with LIKE statement

ASP and Access, problem with LIKE statement

Our Donation Goal : Why Donate? : Donate Today! : Donate Anonymously (ਗੁਪਤ) : Our Family of Supporters
Goal this month: 500 USD, Received: 115 USD (23%)
Please Donate...
     
Related Topics...
Thread Thread Starter Forum Replies Last Post
How to use an IF Statement in Access Z Information Technology 1 28-Jul-2006 08:42 AM
How do I use a SQL statement in an MS Access data access page (HT. Don Michaels Information Technology 0 28-Jul-2006 08:37 AM
Numeric If...Then...Elseif:...Else...End If statement problem Jim Ory Information Technology 2 28-Jul-2006 08:16 AM
insert statement problem jonathandrott@gmail.com Information Technology 4 28-Jul-2006 08:10 AM
Problem with If statement and combo box value Jones Barton Information Technology 2 28-Jul-2006 08:03 AM


Tags
asp, access, problem, statement
Reply Post New Topic In This Forum Stay Connected to Sikhism, Click Here to Register Now!
  #1 (permalink)  
Old 28-Jul-2006, 08:41 AM
signups@creativejam.co.uk's Avatar signups@creativejam.co.uk
Guest
 
Posts: n/a
   
   
ASP and Access, problem with LIKE statement

  Donate Today!   Email to Friend  Tell a Friend   Show Printable Version  Print   Contact sikhphilosophy.net Administraion for any Suggestions, Ideas, Feedback.  Feedback  

Register to Remove Advertisements
Hi,

I have an ASP page which uses a LIKE statement to get products back.
The syntax as far as I can tell is near perfect but it just doesn't
return any records, grrrr.


By running it directly in Access (Using * in place of %) it works like
a charm.


I am using Access 2003, my connection string is:
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/information-technology/13925-asp-and-access-problem-like-statement.html
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=13925
connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
strDabaseName & ";"


The SQL String comes out as:
Select * from tbl_products Where name like '%Roadster%' And active = 1
order by name


Any ideas?


Cheers



Got anything to share on This Topic? Why not share your immediate thoughts/reaction with us! Login Now! or Sign Up Today! to share your views... Gurfateh!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 28-Jul-2006, 08:41 AM
Brendan Reynolds's Avatar Brendan Reynolds
Guest
 
Posts: n/a
   
   
Re: ASP and Access, problem with LIKE statement


There's nothing visibly wrong with that SQL statement. 'Name' is a reserved
word, and using it as a field name can cause problems, but those problems
generally result in an error message. You might want to put square brackets
around the two instances of 'name' in the SQL statement. I don't expect it
to solve this problem, but it may prevent other problems in the future ...

Select * from tbl_products Where [name] like '%Roadster%' And active = 1
order by [name]

Have you tested the SQL statement without the second part of the WHERE
clause ('And active = 1')? Does the following SQL statement return any
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=13925
records? ...

Select * from tbl_products Where [name] like '%Roadster%' order by [name]

--
Brendan Reynolds
Access MVP

wrote in message
news:1153863598.607902.327400@i42g2000cwa.googlegr oups.com...
> Hi,
>
> I have an ASP page which uses a LIKE statement to get products back.
> The syntax as far as I can tell is near perfect but it just doesn't
> return any records, grrrr.
>
>
> By running it directly in Access (Using * in place of %) it works like
> a charm.
>
>
> I am using Access 2003, my connection string is:
> connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
> strDabaseName & ";"
>
>
> The SQL String comes out as:
> Select * from tbl_products Where name like '%Roadster%' And active = 1
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=13925
> order by name
>
>
> Any ideas?
>
>
> Cheers
>



Reply With Quote
  #3 (permalink)  
Old 28-Jul-2006, 08:41 AM
Jamie Collins's Avatar Jamie Collins
Guest
 
Posts: n/a
   
   
Re: ASP and Access, problem with LIKE statement


Brendan Reynolds wrote:
> There's nothing visibly wrong with that SQL statement. 'Name' is a reserved
> word


NAME is a reserved word in Access but not a reserved word in Jet 4.0,
standard SQL, ODBC etc.
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=13925

Jamie.

--

Reply With Quote
  #4 (permalink)  
Old 28-Jul-2006, 08:42 AM
Pieter Wijnen's Avatar Pieter Wijnen
Guest
 
Posts: n/a
   
   
Re: ASP and Access, problem with LIKE statement

It is safer however to allways prefix Fields, and stay away from "dangerous"
names

ie SELECT A.NAME FROM MYTABLE A

Pieter

"Jamie Collins" wrote in message
news:1153919361.746534.176120@75g2000cwc.googlegro ups.com...
>
> Brendan Reynolds wrote:
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=13925
>> There's nothing visibly wrong with that SQL statement. 'Name' is a
>> reserved
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=13925
>> word

>
> NAME is a reserved word in Access but not a reserved word in Jet 4.0,
> standard SQL, ODBC etc.
>
> Jamie.
>
> --
>




--
----------------------------------------
I am using the free version of SPAMfighter for private users.
It has removed 4367 spam emails to date.
Paying users do not have this message in their emails.
Get the free SPAMfighter here: http://www.spamfighter.com/len


Reply With Quote
  #5 (permalink)  
Old 28-Jul-2006, 08:42 AM
Jamie Collins's Avatar Jamie Collins
Guest
 
Posts: n/a
   
   
Re: ASP and Access, problem with LIKE statement


Pieter Wijnen wrote:
> It is safer however to allways prefix Fields, and stay away from "dangerous"
> names
>
> ie SELECT A.NAME FROM MYTABLE A


In you example, A is a 'correlation name' or 'alias' to use the
vernacular. I think of 'prefix' as being something quite different e.g.
a representative term or qualifier in a data element name (e.g. the
'last' in 'last_name') or possibly less salubrious connotations e.g.
Hungarian notation to indicate aspects the physical implementation or
the Access UI. Semantic, yes, but then we are discussing SQL syntax

I agree that if you consider a name to be dangerous then you should
avoid it, as would I. I consider 'Name' to be vague (e.g. missing a
representative term or qualifier) rather than dangerous.

I do not consider that using a table correlation name makes a dangerous
column name less dangerous.

I don't agree that a correlation name should *always* be used. For
example:

DELETE
FROM MYTABLE AS A;

According to the SQL-92 standard, this should materialize a new table,
remove all its rows then disappear, leaving MYTABLE untouched. As we
know, Access/Jet violates the standards, i.e. all rows will be removed
from MYTABLE, but that's no excuse to write non-standard SQL when the
standard syntax is also supported.

However, for vanilla SELECT queries I agree that always using a
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=13925
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=13925
correlation name is a good habit to get into, even for one-table
queries (e.g. makes life easier when you need to change it to a
two-table query). I like the idea of specifying each table's
correlation name in the data dictionary for consistency but admit I
usually just use a single letter (not always consistent between
queries) with an incremental number based on nesting e.g. T1, T2, etc.

Jamie.

--

Reply With Quote
  #6 (permalink)  
Old 28-Jul-2006, 08:42 AM
Pieter Wijnen's Avatar Pieter Wijnen
Guest
 
Posts: n/a
   
   
Re: ASP and Access, problem with LIKE statement

The A.NAME contains a prefix though.
DELETE FROM MYTABLE does not include fields, ergo no aliasing needed/wanted
anyway.
I Always Alias my tables in SELECT queries for readability/editability of
the SQL,
as the GUI version of the Query builder tends to break a lot of my Queries
(the dreaded 'Query to complex')

Check this kind of SQL's before & After you've made an edit in the GUI:

SELECT ....
FROM ...
WHERE (A.ID=0 OR A.ID=Forms!x!AID)
AND (B.ID=0 OR B.ID=Forms!x!BID)
AND (C.ID=0 OR C.ID=Forms!x!CID)
etc

SELECT ....
FROM ...
WHERE EXISTS (SELECT 'X' .....)

SELECT ....
FROM ...
WHERE NOT EXISTS (SELECT 'X' .....)

And, Yes as You I Use "Standarized" Aliases too, and is also not 100%
consistent about it
I think therefore we are pretty much on the same level regarding the way SQL
should look

Pieter

"Jamie Collins" wrote in message
news:1153986408.804034.52710@i3g2000cwc.googlegrou ps.com...
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=13925
>
> Pieter Wijnen wrote:
>> It is safer however to allways prefix Fields, and stay away from
>> "dangerous"
>> names
>>
>> ie SELECT A.NAME FROM MYTABLE A

>
> In you example, A is a 'correlation name' or 'alias' to use the
> vernacular. I think of 'prefix' as being something quite different e.g.
> a representative term or qualifier in a data element name (e.g. the
> 'last' in 'last_name') or possibly less salubrious connotations e.g.
> Hungarian notation to indicate aspects the physical implementation or
> the Access UI. Semantic, yes, but then we are discussing SQL syntax
>
> I agree that if you consider a name to be dangerous then you should
> avoid it, as would I. I consider 'Name' to be vague (e.g. missing a
> representative term or qualifier) rather than dangerous.
>
> I do not consider that using a table correlation name makes a dangerous
> column name less dangerous.
>
> I don't agree that a correlation name should *always* be used. For
> example:
>
> DELETE
> FROM MYTABLE AS A;
>
> According to the SQL-92 standard, this should materialize a new table,
> remove all its rows then disappear, leaving MYTABLE untouched. As we
> know, Access/Jet violates the standards, i.e. all rows will be removed
> from MYTABLE, but that's no excuse to write non-standard SQL when the
> standard syntax is also supported.
>
> However, for vanilla SELECT queries I agree that always using a
> correlation name is a good habit to get into, even for one-table
> queries (e.g. makes life easier when you need to change it to a
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=13925
> two-table query). I like the idea of specifying each table's
> correlation name in the data dictionary for consistency but admit I
> usually just use a single letter (not always consistent between
> queries) with an incremental number based on nesting e.g. T1, T2, etc.
>
> Jamie.
>
> --
>



Reply With Quote
  #7 (permalink)  
Old 28-Jul-2006, 08:42 AM
Pieter Wijnen's Avatar Pieter Wijnen
Guest
 
Posts: n/a
   
   
Re: ASP and Access, problem with LIKE statement

  Donate Today!  
The A.NAME contains a prefix though.
DELETE FROM MYTABLE does not include fields, ergo no aliasing needed/wanted
anyway.
I Always Alias my tables in SELECT queries for readability/editability of
the SQL,
as the GUI version of the Query builder tends to break a lot of my Queries
(the dreaded 'Query to complex')

Check this kind of SQL's before & After you've made an edit in the GUI:

SELECT ....
FROM ...
WHERE (A.ID=0 OR A.ID=Forms!x!AID)
AND (B.ID=0 OR B.ID=Forms!x!BID)
AND (C.ID=0 OR C.ID=Forms!x!CID)
etc

SELECT ....
FROM ...
WHERE EXISTS (SELECT 'X' .....)

SELECT ....
FROM ...
WHERE NOT EXISTS (SELECT 'X' .....)

And, Yes as You I Use "Standarized" Aliases too, and is also not 100%
consistent about it
I think therefore we are pretty much on the same level regarding the way SQL
should look

Pieter

"Jamie Collins" wrote in message
news:1153986408.804034.52710@i3g2000cwc.googlegrou ps.com...
>
> Pieter Wijnen wrote:
>> It is safer however to allways prefix Fields, and stay away from
>> "dangerous"
>> names
>>
>> ie SELECT A.NAME FROM MYTABLE A

>
> In you example, A is a 'correlation name' or 'alias' to use the
> vernacular. I think of 'prefix' as being something quite different e.g.
> a representative term or qualifier in a data element name (e.g. the
> 'last' in 'last_name') or possibly less salubrious connotations e.g.
> Hungarian notation to indicate aspects the physical implementation or
> the Access UI. Semantic, yes, but then we are discussing SQL syntax
>
> I agree that if you consider a name to be dangerous then you should
> avoid it, as would I. I consider 'Name' to be vague (e.g. missing a
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=13925
> representative term or qualifier) rather than dangerous.
>
> I do not consider that using a table correlation name makes a dangerous
> column name less dangerous.
>
> I don't agree that a correlation name should *always* be used. For
> example:
>
> DELETE
> FROM MYTABLE AS A;
>
> According to the SQL-92 standard, this should materialize a new table,
> remove all its rows then disappear, leaving MYTABLE untouched. As we
> know, Access/Jet violates the standards, i.e. all rows will be removed
> from MYTABLE, but that's no excuse to write non-standard SQL when the
> standard syntax is also supported.
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=13925
>
> However, for vanilla SELECT queries I agree that always using a
> correlation name is a good habit to get into, even for one-table
> queries (e.g. makes life easier when you need to change it to a
> two-table query). I like the idea of specifying each table's
> correlation name in the data dictionary for consistency but admit I
> usually just use a single letter (not always consistent between
> queries) with an incremental number based on nesting e.g. T1, T2, etc.
>
> Jamie.
>
> --
>




--
----------------------------------------
I am using the free version of SPAMfighter for private users.
It has removed 4367 spam emails to date.
Paying users do not have this message in their emails.
Get the free SPAMfighter here: http://www.spamfighter.com/len


Reply With Quote
   Click Here to Donate Now!

Support Us!
Become a Promoter!
Gurfateh ji, you can become a SPN Promoter by Donating as little as $10 each month. With limited resources & high operational costs, your donations make it possible for us to deliver a quality website and spread the teachings of the Sri Guru Granth Sahib Ji, to serve & uplift humanity. Every contribution counts. Donate Generously. Gurfateh!
ReplyPost New Topic In This Forum Stay Connected to Sikhism, Click Here to Register Now!

Bookmarks


(View-All Members who have read this thread : 0
There are no names to display.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Tools Search
Search:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On

» Active Discussions
Man Driving Without...
Today 00:28 AM
3 Replies, 60 Views
Do you believe in...
Today 00:25 AM
192 Replies, 4,001 Views
Keeping Amrit Vela
Yesterday 23:38 PM
10 Replies, 846 Views
How does Sikhi help you...
Yesterday 22:54 PM
22 Replies, 872 Views
Losing My Religion: Why...
Yesterday 22:18 PM
12 Replies, 274 Views
Request for assistance...
Yesterday 21:53 PM
5 Replies, 45 Views
Panjabi
By Ishna
Yesterday 17:56 PM
12 Replies, 259 Views
Parkash Guru Amar Das ji...
Yesterday 17:07 PM
3 Replies, 32 Views
Serious challenges to...
Yesterday 16:49 PM
0 Replies, 55 Views
Sikh man fights for his...
Yesterday 16:46 PM
0 Replies, 57 Views
Sikhs Rights Group to...
Yesterday 16:44 PM
0 Replies, 36 Views
Haryana Sikh body bans...
Yesterday 16:39 PM
0 Replies, 37 Views
Health Exercise And...
Yesterday 13:30 PM
0 Replies, 55 Views
SSGS with English...
Yesterday 12:55 PM
9 Replies, 119 Views
Rozana Reports (ਪੰਜਾਬੀ...
Yesterday 01:44 AM
310 Replies, 7,559 Views
» Books You Should Read...
Powered by vBadvanced CMPS v3.2.3
All times are GMT +6.5. The time now is 00:53 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2 Copyright © 2004-12, All Rights Reserved. Sikh Philosophy Network


Page generated in 0.52576 seconds with 32 queries
0