Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Display value of query result in ASP

Posted on 2008-06-14
2
Medium Priority
?
448 Views
Last Modified: 2009-12-16
Hi Experts,

This seems simple enough but I can't figure it out or find a solution,  all I want to do is execute a sql query
sqlNewClients = "SELECT COUNT(AdvisorID) AS NewAdvisorID FROM TFN_Advisors"
And write the result in my ASP page

I need to replace There Are sqlNewClients  with the correct syntax.  Thanks

Dim objCmd
Set objCmd = Server.Createobject("ADODB.Connection")
strConnectionString = "Driver={SQL SERVER};Server=XXX.XX.XXX.XXX;Database=NAME;Uid=user;Pwd=password"
objCmd.Open strConnectionString
objCmd.Execute sqlNewClients
Set objCmd = Nothing
Response.Write("NewAdvisorID")
%>
<BR>
<font color ="navy" size=5><b><%="There Are sqlNewClients %>
<BR>

Open in new window

0
Comment
Question by:millerfw
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Author Comment

by:millerfw
ID: 21787100
I forgot to add that if the values is zero I want to return the the home site if the values is >0 i want to return to the previous page.  I am assuming I can just right a function to do this just like in HTML.
0
 
LVL 14

Accepted Solution

by:
_Stilgar_ earned 750 total points
ID: 21788495
See code below
Dim objConn, strSQL, rs, val
Set objConn = Server.Createobject("ADODB.Connection")
strConnectionString = "Driver={SQL SERVER};Server=XXX.XX.XXX.XXX;Database=NAME;Uid=user;Pwd=password"
objConn.Open strConnectionString
 
strSQL = "SELECT COUNT(AdvisorID) AS NewAdvisorID FROM TFN_Advisors"
set rs = Server.CreateObject("ADODB.RecordSet")
rs.Open strSQL, Site_Conn
val = rs(0).value
rs.close
set rs = nothing
objConn.close
set objConn = nothing
 
if CInt(val)>0 then response.redirect "/" else response.redirect "/previouspage.asp"
%>
<BR>
<font color ="navy" size=5><b><%="There Are sqlNewClients %>
<BR>

Open in new window

0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Screencast - Getting to Know the Pipeline

610 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