Solved

Display value of query result in ASP

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Adding Row and Cell on a table 14 25
Filktering Alphabetically 8 28
Set time on Session (ASP) 14 21
IIS 7 and executing pages using localhost 16 12
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…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

792 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