Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 18th, 2003, 12:40 PM
Authorized User
 
Join Date: Nov 2003
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default "Single-Record" Recordset

My ASP page calls a stored procedure that returns a recordset. Sometimes, the recordset consists only of a single record. In this situation, I cannot get the record to display. The page works fine when there are no records or when there are multiple records. I need to design an IF-THEN-ELSE statement to handle each of these situations, but I cannot figure out how to specify the condition where there is only one record. Can anyone help me?

Thanks in advance.
 
Old November 18th, 2003, 12:45 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

If your code is set up right you shouldn't have this problem.

Can you post the code where you deal with the recordset?

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old November 18th, 2003, 01:20 PM
Authorized User
 
Join Date: Nov 2003
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here you go:

<%
  Dim strConnect
%>


<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
</HEAD>
<BODY>
<%
    Dim strDatabaseName, objComm
    strServerName = Request.Form("ServerName")

    Set objComm = Server.CreateObject("ADODB.Command")

    objComm.ActiveConnection = strConnect
    objComm.CommandText = "ap_RemoteDBName" 'Here's where you specify the stored procedure
    objComm.CommandType = adCmdStoredProc

    objComm.Parameters.Append objComm.CreateParameter("@ServerName", adVarChar, _
        adParamInput, 50, strServerName)

    Set objRS = objComm.Execute

    If objRS.BOF and objRS.EOF then
      Response.Write strServerName & " holds the following database:<br><br>"
      Response.Write "<table border=1>"
      Response.Write "<tr><td><b>Database Name</b></td></tr>"
      strDatabaseName = objRS("DataBase_Name")
      Response.Write "<tr><td>" & strDatabaseName & "</td></tr>"
      Response.Write "</table>"
    ElseIf objRS.BOF and not objRS.EOF then
      Response.Write strServerName & " holds the following databases:<br><br>"
      Response.Write "<table border=1>"
      Response.Write "<tr><td><b>Database Name</b></td></tr>"
      objRS.MoveFirst
      While Not objRS.EOF
        strDatabaseName = objRS("DataBase_Name")
        Response.Write "<tr><td>" & strDatabaseName & "</td></tr>"
        objRS.MoveNext
      Wend
      Response.Write "</table>"
    Else
      Response.Write strServerName & " contains no databases."
    End If
    objRS.Close
    Set objRS=Nothing
    Set objComm=Nothing
%>
</BODY>
</HTML>





Similar Threads
Thread Thread Starter Forum Replies Last Post
Repeat single record in Crystal Report? jpryor Crystal Reports 1 April 11th, 2008 10:20 AM
Help in appending a single record. prashanthmcr SQL Language 0 December 14th, 2005 08:47 PM
How do I append a single record ??? prashanthmcr SQL Language 3 December 14th, 2005 05:40 PM
Display a single record.. PLEASE HELP TnTandyO Classic ASP Databases 26 September 9th, 2003 10:34 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.