Results 1 to 5 of 5

Thread: What's wrong with this SQL statement?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2002
    Posts
    665

    Question What's wrong with this SQL statement?

    I use Oracle 10g with Client9

    In SQL Navigator this works:
    Code:
    SELECT (SELECT Count(*) from tbllev) totalrows, salesorder, customer, idt FROM tblLev
    But when I use exactly same SQL from VB it doesen't work?
    vb Code:
    1. SQL = "SELECT (SELECT Count(*) from tblLev) totalrows, salesorder, customer, idt FROM tblLev"

    I get error "ORA-00936: missing expression"

    If I remove this from the SQL string: (SELECT Count(*) from tblLev) totalrows, it works from VB?
    Last edited by Pirre001; Feb 27th, 2007 at 12:19 PM.

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: What's wrong with this SQL statement?

    I'm not sure, but aren't you missing a comma?

    "SELECT (SELECT Count(*) from tblLev), totalrows, salesorder, customer, idt FROM tblLev"
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

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

    Re: What's wrong with this SQL statement?

    Nooooo, he's not missing a coma.... that's the field alias for the SELECT....

    Squeeze an "AS" between the ")" and "totalrows" ....

    Double check your connection string and make sure you are using an Oracle provider and not a generic ODBC provider.

    -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??? *

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2002
    Posts
    665

    Re: What's wrong with this SQL statement?

    I've checked again and found that the oracle provider I use "Provider=OraOLEDB.Oracle" is not working with this kind of query.
    If I change provider to Microsofts "Provider=msdaora" it works?

    Can some one tell me why it is so?

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

    Re: What's wrong with this SQL statement?

    It's something that was implemented in one provider that wasn't done in the other. For anything more complete than that, you'd have to talk to those who wrote the providers.

    -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??? *

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