Results 1 to 5 of 5

Thread: Ado Error

  1. #1

    Thread Starter
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    Ado Error

    Anybody got any idea why this causes VB to perform an illegal operation and crash?

    VB Code:
    1. rsRes.Open "SELECT DISTINCT (ASampleName, BSampleName )" & _
    2.             "FROM tblTests " & _
    3.             "WHERE TestName = " & Chr(34) & _
    4.             frmMain.cboTest.Text & Chr(34) & _
    5.             " AND Archived = false", _
    6.             cnnCon, _
    7.             adOpenKeyset, _
    8.             adLockReadOnly, _
    9.             adCmdText

  2. #2
    Addicted Member Supester's Avatar
    Join Date
    Nov 2001
    Location
    The Netherlands
    Posts
    220
    SELECT DISTINCT (ASampleName, BSampleName )
    I think you cannot use distinct that way.......did u try it directly in the database?

  3. #3

    Thread Starter
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479
    I think you cannot use distinct that way.......did u try it directly in the database?
    You're correct even Access hangs.

  4. #4
    Helger
    Guest
    You need to pass that parameter in a different way. rs.open and parameters don't work too great.

    First try something else tho: you forgot a space in the first line of your SQL, I believe.

    Instead of passing the whole line like this put it in a stringvariable first:

    VB Code:
    1. strQry = "SELECT DISTINCT (ASampleName, BSampleName ) " & _ 'space missing in front of last parantheses
    2.             "FROM tblTests " & _
    3.             "WHERE TestName = " & Chr(34) & _
    4.             frmMain.cboTest.Text & Chr(34) & _
    5.             " AND Archived = false;)
    6. ....
    7.  
    8. rs.open strQry,...

    Helger

  5. #5
    Hyperactive Member Granty's Avatar
    Join Date
    Mar 2001
    Location
    London
    Posts
    439
    Did you try without the brackets?

    Code:
    SELECT DISTINCT ASampleName, BSampleName

    Oh, and how many records does the table hold?

    J.

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