Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1083479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:26:28+00:00 2026-05-16T22:26:28+00:00

I’m writing some simple queries which return a single value and I’d like to

  • 0

I’m writing some simple queries which return a single value and I’d like to get the ADO.NET ExecuteScalar method’s behavior from Classic ASP’s ADO libary. However, I’d prefer to not re-invent the wheel. Is it possible to instantiate ADO.NET’s Command object within classic ASP? If so, how would I go about doing that?

If I do need to re-implement this feature, what is the best way to do that?

Here’s what I’m trying to do (In VBScript):

set cmd = Server.CreateObject("ADODB.Command")
cmd.ActiveConnection = conn
cmd.CommandText = "SELECT COUNT(*) FROM corp_crcchallenge WHERE cc_email = ?"
appendParam cmd, "email", adVarChar, adParamInput, 255, email
emailFound = cmd.ExecuteScalar()

appendParam is a subroutine I made to append the param so I wouldn’t have to repeat myself too much in another part of this app. It makes it a bit easier to read.

I’m thinking that something like the below might be the right direction if I need to re-implement. (Again VBScript)

emailFound = cmd.Execute(Nothing, Nothing, adExecuteRecord)
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T22:26:29+00:00Added an answer on May 16, 2026 at 10:26 pm

    The command object returns data as recordset. You can get the value from the recordsets field. In this example, I have used a defined field name of “MyCount”. If you wanted a more generic, you could just get the value of rs.fields(0) in the last line.

    Quick Example:

    set cmd = Server.CreateObject("ADODB.Command")
    set rs = server.createObject("ADODB.RecordSet")
    
    with cmd
     .ActiveConnection = conn
     .CommandText = "SELECT COUNT(*) as MyCount FROM corp_crcchallenge WHERE cc_email = @p1"
     .createparameter("@p1",adVArChar,adParamInput,,email)
     set rs = .Execute
    end with
    
    rtn = rs.fields("MyCount")
    

    Reusable function example:

    n = MyScalar("SELECT COUNT(*) FROM corp_crcchallenge WHERE cc_email = @p1","abc@def.com")
    
    function MyScalar(sql, Param1)
        set cmd = Server.CreateObject("ADODB.Command")
        set rs = server.createObject("ADODB.RecordSet")
    
        with cmd
            .ActiveConnection = conn
            .CommandText = sql
            .createparameter("@p1",adVArChar,adParamInput,,Param1)
            set rs = .Execute
        end with
    
        MyScalar = rs.fields(0)
    
    end function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I would like to run a str_replace or preg_replace which looks for certain words
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.