Solved

Display value of query result in ASP

Posted on 2008-06-14
2
442 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 250 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

688 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