Results 1 to 8 of 8

Thread: [RESOLVED] Select Count Distinct

  1. #1

    Thread Starter
    Addicted Member Alexandru_mbm's Avatar
    Join Date
    Jul 2007
    Location
    VBForums.com
    Posts
    157

    Resolved [RESOLVED] Select Count Distinct

    Anyone can help me with this code ?!

    Code:
            Dim cn As New OleDbConnection(Conexiune)
            Dim SQLResult As Object
            Dim SQL As New OleDbCommand
            cn.Open()
            SQL.Connection = cn
            SQL.CommandText = "SELECT COUNT(DISCTINCT(editura)) FROM lista_carti)"
            SQLResult = SQL.ExecuteScalar
            Me.lbl_nr_edituri.Text = SQLResult
    
            cn.Close()
    I have this error: Syntax error in FROM clause.

    Why this is not working with access databases !?
    I'm still learning VB.NET
    Sorry for my bad english
    Thanks for your help

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Select Count Distinct

    You have one too many closing parenthesis....

    it should be
    Code:
    "SELECT COUNT(DISCTINCT(editura)) FROM lista_carti"
    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Addicted Member Alexandru_mbm's Avatar
    Join Date
    Jul 2007
    Location
    VBForums.com
    Posts
    157

    Re: Select Count Distinct

    Thanks alot techgnome...

    Now i have this one: Undefined function 'DISTINCT' in expression.
    I'm still learning VB.NET
    Sorry for my bad english
    Thanks for your help

  4. #4

    Thread Starter
    Addicted Member Alexandru_mbm's Avatar
    Join Date
    Jul 2007
    Location
    VBForums.com
    Posts
    157

    Re: Select Count Distinct

    I did it!

    Code:
    SQL.CommandText = "SELECT COUNT(*) FROM (SELECT DISTINCT editura FROM lista_carti)"
    Thanks again for your big help!
    I'm still learning VB.NET
    Sorry for my bad english
    Thanks for your help

  5. #5
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    UK
    Posts
    285

    Re: Select Count Distinct

    Its been years since I did Access, but isn't it DistinctCount? (One word).

    In SQL Server 2000, the query would be written:
    SQL.CommandText = "SELECT COUNT(DISTINCT editura) FROM lista_carti"
    Last edited by bigMeUp; Dec 10th, 2007 at 06:20 PM.

  6. #6
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    UK
    Posts
    285

    Re: Select Count Distinct

    Oh, you did it! I really have to read these eff**g posts before I tap keyboard, innit?

  7. #7

    Thread Starter
    Addicted Member Alexandru_mbm's Avatar
    Join Date
    Jul 2007
    Location
    VBForums.com
    Posts
    157

    Re: [RESOLVED] Select Count Distinct

    I did it bigMeUp!

    I dont think is in one word... i did not find anywhere something like that!

    Thanks anyway for your help!
    I'm still learning VB.NET
    Sorry for my bad english
    Thanks for your help

  8. #8
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    UK
    Posts
    285

    Re: [RESOLVED] Select Count Distinct

    Excellent, Alexandru_mbm! As a matter of interest, does
    Code:
    SQL.CommandText = "SELECT COUNT(DISTINCT editura) FROM lista_carti"
    work?

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