Sign Up |  Live StatsLive Stats    Articles 35,345| Comments 159,790| Members 17,820, Newest waheguruhelpme| Online 223
Home Contact
 (Forgotten?): 
    Sikhism

   
                                                                     Your Banner Here!    

Sikh Philosophy Network » Sikh Philosophy Network » Current Affairs » 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: 400 USD, Received: 35 USD (9%)
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.
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/information-technology/13925-asp-and-access-problem-like-statement.html


By running it directly in Access (Using * in place of %) it works like
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=13925
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
order by name


Any ideas?


Cheers




 
Do share your immediate thoughts or reactions on this issue? We value your views! Login Now! or Sign Up Today! to share your views with us.. 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
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=13925
clause ('And active = 1')? Does the following SQL statement return any
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:
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
> word


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

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"
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=13925
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:
>> There's nothing visibly wrong with that SQL statement. 'Name' is a
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=13925
>> reserved
>> 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
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=13925

I agree that if you consider a name to be dangerous then you should
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=13925
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
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')
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=13925

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.
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=13925
> 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
> 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.
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=13925
> 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
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=13925
> 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
> 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

» Gurbani Jukebox
Listen to Gurbani while surfing SPN!
» Active Discussions
sikhism Who is "Mohan"?
Today 08:46 AM
22 Replies, 335 Views
sikhism How important is Matha...
Today 08:12 AM
59 Replies, 1,038 Views
sikhism need urgent advice.......
Today 06:46 AM
6 Replies, 81 Views
sikhism ਨਾਮਾ
Today 06:37 AM
2 Replies, 53 Views
sikhism Sikh Diamonds Video...
Today 04:23 AM
6 Replies, 116 Views
sikhism Are Creator and Creation...
Today 01:30 AM
44 Replies, 2,837 Views
sikhism Herman Hesse,...
Today 00:54 AM
13 Replies, 229 Views
sikhism On a Scale of Most...
Yesterday 21:42 PM
30 Replies, 1,277 Views
sikhism I became victim by...
Yesterday 19:50 PM
0 Replies, 44 Views
sikhism Sikh Books downloads
Yesterday 15:39 PM
2 Replies, 66 Views
sikhism Salok Sheikh Farid ji...
Yesterday 09:35 AM
0 Replies, 47 Views
sikhism In Punjab, three farmers...
Yesterday 05:36 AM
0 Replies, 49 Views
sikhism Supernatural Sikhs, what...
Yesterday 03:45 AM
19 Replies, 414 Views
sikhism Sukhmani Sahib Astpadi...
26-May-2012 22:57 PM
0 Replies, 51 Views
Do You Think You Are...
26-May-2012 09:59 AM
94 Replies, 8,258 Views
» Books You Should Read...
Powered by vBadvanced CMPS v3.2.2

All times are GMT +6.5. The time now is 09:47 AM.
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.5.2 Copyright © 2004-12, All Rights Reserved. Sikh Philosophy Network


Page generated in 0.46757 seconds with 30 queries