CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2000
    Location
    Finland, Joensuu
    Posts
    2

    Why DISTINCT -command does not work with ADO?

    Hello

    I'm using ADO connection.

    I have this kind on code:

    ...
    Dim rsRecordset As ADODB.Recordset
    Let rsRecordset.CursorLocation = adUseClient
    Call rsRecordset.Open("SELECT DISTINCT A, B FROM ...", conDB, adOpenKeyset,
    adLockOptimistic, adCmdText)

    The DISTINCT does not work; it has no effect: if I do select-directly to the
    database (for example with Oracle Sql*Plus), I get 1 row, but rsRecordset retunrs
    2 rows.

    "GROUP BY " - seems to work...

    We use Oracle-database.

    How can I get DISTINCT-work? (This is a quite big problem in our project at the
    moment.)

    - I'm using NT 4.0

    Thank you.


  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Why DISTINCT -command does not work with ADO?

    First of all check the syntax of the distinct keyword for your database. They are slightly different for different databases. It can be DISTINCT or DISTINCTROW.
    Second,
    In your SQL SELECT DISTINCT A, B FROM , the recordset will return distinct combination of A and B. If you want only distinct A you have to write
    SELECT DISTINCT A FROM

    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  3. #3
    Join Date
    Jul 2000
    Location
    Finland, Joensuu
    Posts
    2

    Re: Why DISTINCT -command does not work with ADO?

    Thank you. I tried DISTINCTROW, but it seems, that my database does not regognize it.

    I already found one solution from the link:

    http://support.microsoft.com/support.../q181/4/79.asp

    It works when I use adUseServer instead of adUseClient like it was said in link.

    Juha


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

Featured