Results 1 to 6 of 6

Thread: Basic SQL statement

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2002
    Posts
    102

    Basic SQL statement

    I am trying to locate a single record from a table by using the statement



    ado.recordsource = SELECT FROM ClientDetails WHERE ClientID =temp



    Because ClientID is the primary key (and the variable temp contains the required ClientID number), I would expect the recordset to only return one record - except it doesn't. When searching through the result in debug, it seems to go through every record in the table.

    What Am I doing wrong?
    Last edited by darthy; Oct 5th, 2002 at 11:31 AM.

  2. #2
    Lively Member
    Join Date
    Jun 2002
    Location
    Kuwait
    Posts
    85
    Is "ado" a datacontrol or what? n where are you assigning the value for variable temp? can you post your piece of code.
    Your attitude determines your altitude!!!

  3. #3
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Well

    VB Code:
    1. ado.recordsource = SELECT * FROM ClientDetails WHERE ClientID = '" & temp & "'"
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Feb 2002
    Posts
    102
    When I use the code mentioned above I get Error - Expected Expression


    Code:
    Ado.RecordSource = SELECT * FROM Client WHERE ClientID = '" & temp & "'""

    But when I put extra quotes ie

    Code:
    Ado.RecordSource = "SELECT * FROM Client WHERE ClientID = '" & temp & "'"""
    The Expected expression goes away but then I get a Error in FROM Clause

    Any Ideas?

  5. #5
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Well

    VB Code:
    1. ado.recordsource = "SELECT * FROM ClientDetails WHERE
    2. ClientID = '" & temp & "'"

    he quote needs to be in front of SELECT
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Feb 2002
    Posts
    102
    Quote is in front of select NOW (my mistake when entering code inside tags)

    But still getting the same error

    In debug it is when I use the refresh method when the error occurs. Could that be something to with it.

    It comes up with Method refresh of ADO failed


    Any ideas?

Posting Permissions

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



Click Here to Expand Forum to Full Width