Solved

Display value of query result in ASP

Posted on 2008-06-14
2
437 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
2 Comments
 

Author Comment

by:millerfw
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

744 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

13 Experts available now in Live!

Get 1:1 Help Now