Results 1 to 5 of 5

Thread: DSN - no records returned from query

  1. #1
    Join Date
    Oct 2006
    Location
    London
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default DSN - no records returned from query

    Hi
    I have a system DSN that points to an access database. Everything works fine on my dev PC and in MS Access itself but on the website there are a couple of queries that return no records. The sql gets used with different critria and some work but others don't. Does anyone have any ideas where to look. I've pasted in a working and non working one, there's so little difference and it works fine in Access and on the Dev PC to the same database.
    Thanks
    Steve

    Here's a working SQL
    SELECT Tblprducts.firstname & ' ' & Tblprducts.surname as Fullname, TblPrducts.ProductCode, TblPrducts.ProductName, TblPrducts.ProductPrice, TblPrducts.Inventory, TBLPrducts.id, TblPrducts.Mancode, TblPrducts.LongDesc, TblPrducts.ProductManufacturer, TblPrducts.RetailPrice, TblPrducts.Image, BibleInfo.Translation1 FROM BibleInfo RIGHT JOIN TblPrducts ON BibleInfo.ProductCode = TblPrducts.ProductCode WHERE (((TblPrducts.ManCode)='Books')) AND TblPrducts.ProductCategory = 'BIBLE REFERENCE' Order By -TBLPrducts.id

    and one the doesn't
    SELECT Tblprducts.firstname & ' ' & Tblprducts.surname as Fullname, TblPrducts.ProductCode, TblPrducts.ProductName, TblPrducts.ProductPrice, TblPrducts.Inventory, TBLPrducts.id, TblPrducts.Mancode, TblPrducts.LongDesc, TblPrducts.ProductManufacturer, TblPrducts.RetailPrice, TblPrducts.Image, BibleInfo.Translation1 FROM BibleInfo RIGHT JOIN TblPrducts ON BibleInfo.ProductCode = TblPrducts.ProductCode WHERE (((TblPrducts.ManCode)='Bibles')) AND TblPrducts.ProductCategory = 'BIBLE SOFTWARE' Order By -TBLPrducts.id

  2. #2
    Join Date
    Jun 2005
    Posts
    1,081
    Thanks
    4
    Thanked 15 Times in 15 Posts

    Default

    Are you sure you have data correctly stored in the tables as you are limiting on 2 different parameters in your query.

    Also double check the spellings in the ProductCategory field as well as checking any padding since you are checking for an exact string.

    I also noticed that you have '-TBLPrducts.id' at the end of the query, and believe this should be 'TBLPrducts.id'.

  3. #3
    Join Date
    Oct 2006
    Location
    London
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for the reply, i'm sure the data is right but I'll check for padding and try using like instead of equals. The minus on -TBLPrducts.id should sort the data inversely. The strange thing is that I've setup a DSN on my XP machine with the same access database file and it works. I'll probably create a new ASP just with the SQL in and try and gradually cut it down till it works.

    cheers

    Steve

  4. #4
    Join Date
    Mar 2005
    Location
    Hampshire
    Posts
    432
    Thanks
    4
    Thanked 3 Times in 3 Posts

    Default

    Quote Originally Posted by socket View Post
    The minus on -TBLPrducts.id should sort the data inversely.
    For sorting you should always use

    ORDER BY column ASC

    or

    ORDER BY column DESC
    Last edited by Warren Ashcroft; 21st October 2006 at 04:45 PM.

    Just chill

  5. #5
    Join Date
    Oct 2006
    Location
    London
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for your help

    it works OK using LIKE instead of = and I have changed the sort to DESC. I'm not sure why it works on my XP machine but haven't got the enthusiasm to look further as it's now working.

    best regards

    STeve

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Odbc Dsn
    By CookingFat in forum Technical Support
    Replies: 3
    Last Post: 12th September 2006, 05:45 PM
  2. SQL: all records of same month
    By Rappie in forum MySQL
    Replies: 1
    Last Post: 24th August 2006, 11:08 PM
  3. Could Someone Please Confirm The Following About DNS Records
    By MWF in forum General Technical Support
    Replies: 6
    Last Post: 7th July 2006, 02:21 PM
  4. Odbc Dsn
    By iomff in forum ASP (VBScript)
    Replies: 1
    Last Post: 18th May 2006, 10:12 AM
  5. .net DSN-less connection...help!
    By creativeworks in forum ASP.NET
    Replies: 4
    Last Post: 23rd June 2005, 05:32 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •