SQL Connection query question

Posted on 2004-11-03
Last Modified: 2010-05-02
I have a SQL Query that is called from a VBScript, something like the following:

Query = "select UserCount from .....
Set Result = objConn.Execute(Query)

It works just fine.  I recently ran into a problem where the query returns no results.  If I do this in ISql I get the same response - no records match the query, so the results window is empty.

How would I go about validating the results?  If I have something like:
wscript.echo Result("UserCount") after a query that returns no results I get an error.

Question by:robrandon
    LVL 26

    Expert Comment

    dim count

    on error resume next   ' this line is import

    count = Result.recordcount
    if (count = 0 ) then
    ' no record
    end if
    LVL 48

    Accepted Solution

    If Not Result .EOf then
    end if

    Check the EOF
    LVL 16

    Author Comment

    Mikal613's is a lot smoother.  Thanks!
    LVL 48

    Expert Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
    This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now