asp tutorials, asp.net tutorials, sample code, and Microsoft news from 15Seconds
Data Access  |   Troubleshooting  |   Security  |   Performance  |   ADSI  |   Upload  |   Email  |   Control Building  |   Component Building  |   Forms  |   XML  |   Web Services  |   ASP.NET  |   .NET Features  |   .NET 2.0  |   App Development  |   App Architecture  |   IIS  |   Wireless
 
Pioneering Active Server
 Power Search





Active News
15 Seconds Weekly Newsletter
• Complete Coverage
• Site Updates
• Upcoming Features

More Free Newsletters
Reference
News
Articles
Code Samples
Components
Tools
New
Free
Downloads
Vendors
FAQ
Feedback
Books
Links
DL Archives
Community
Messageboard
List Servers
Mailing List
WebHosts
Consultants
Tech Jobs
15 Seconds
Home
Site Map
Press
Legal
Privacy Policy
internet.commerce














internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

HardwareCentral
Compare products, prices, and stores at Hardware Central!

When using ADO to access database through Web or in normal Client/server application , we have almost all the mostly used properties/methods required for data/record manipulation and we can also move to next recordset but there is no property/method to know how many recordset are returned by query or stored proc. The following code lets you know how many recordsets are returned by a query/stored proc. :


function get_number_of_recordset (rs)
   i = 0 		
   while not rs is nothing
       ' insert your code here (optional only if u want to)
       i = i + 1		
       set rs = rs.NextRecordset 
   wend
   get_number_of_recordset = i
end function


Here you just pass an reference of an recordset as argument to get_number_of_recordset function which then will return integer value indicating the total no. of recordset that exists as a result of the execution of query or stored procedure. The above function can be directly incorporated into your asp page with no modification , but to use the above in normal VB application the following code should be incorporated :


function get_number_of_recordset (byref rs as ADODB.Recorset) as integer
dim i as integer
   i = 0 		
   while not rs is nothing
       i = i + 1		
       set rs = rs.NextRecordset 
   wend
   get_number_of_recordset = i
end function


The Following example shows the utilization of the above function :


< --- recodset.asp --- >

function get_number_of_recordset (rs)
   i = 0 		
   while not rs is nothing
       i = i + 1		
       set rs = rs.NextRecordset 
   wend
   get_number_of_recordset = i
end function

set conn = Server.CreateObject ( "Adodb.Connection" )
set rs = server.CreateObject ( "Adodb.recordset" )
set cmd = server.CreateObject ( "Adodb.command" )

conn.open "yourdsn"            rem specify your dsn

set cmd.ActiveConnection = conn
	
cmd.CommandText = "sp_help ""your table name"" "  rem here you can write your normal rem sql stmt also instead of sp_help "your table name"

set rs = cmd.Execute ()

rem sp_help is SQL Server system stored proc. returns 7 recordsets where each recordset gives the charcteristic of your table, for eg, your table structure , primary key - foreign key , indexes , indentity field information etc.

Response.write ("The No. Of Recordsets Returned Are :" & get_number_of_recordset(rs) )


< --- recodset.asp --- >


By Modifying the function ie.(replacing insert your code line with your actuall code ) you can incorporate your functionality depending upon your task. Event though you dont replace that line still code would function well.




email this code sample to a colleague

Related Articles
Dec 10, 1996 - ODBC 3.0 Connection Pooling
This issue of 15 Seconds contain an example of how to create an ISAPI server extension in MSVC 4.2 with ODBC 3.0 connection pooling. There is also an evaluation of ODBC 3.0, OLEDB, ADO and DAO.
[Read This Article]  [Top]
May 31, 1997 - Connection Pooling with ASP
Connection pooling might be the easiest way to speed up your dynamic web pages reading from SQL Server. Unfortunately, connection pooling within is turned off by default in Active Server pages. Probably because connection pooling is rarely understood in its entirety. This issue discusses connection pooling with ASP, ISAPI, IDC, and Visual Basic applications. Included is a discussion about ODBC 3.0 and the newest bug fix for ODBC.
[Read This Article]  [Top]
Apr 15, 1998 - File Repository Weblication using IIS 4.0
In this article Amos El-Roy demonstrates how to create a file repository using ASP pages. A seamless approach that maximizes accessibility and lowers administrative overhead is illustrated in the article's example, which is available for download.
[Read This Article]  [Top]
Oct 21, 1999 - Updating Excel From the Web
Bill Jeffries's article on Excel's Web Query tool demonstrates how to update selected spreadsheet cells instantly over an HTTP connection.
[Read This Article]  [Top]
Nov 11, 1999 - Database-Driven WWW Help System
The help system presented in Vujosevic and Laberge's article is self contained and can be updated and altered without impacting the original Web application. Much like an online book, the help icon in the Web application dives into an application system for the help option. Each Web page has its own separate help page with a database that contains one row in a table for every calling Web page. Sample code is provided.
[Read This Article]  [Top]
Jan 31, 2000 - ASP-Oracle Connectivity Using OO4O
Selva Kumar’s article shows how to create practical Oracle database connectivity from ASP using Oracle Objects for OLE (OO4O). OO40, the Oracle middleware, allows native access to Oracle from client applications using the Microsoft Object Linking and Embedding (OLE) standard. Sample code is provided.
[Read This Article]  [Top]
Mar 9, 2000 - SQL Solutions
Cindy Cruciger claims there is a better way to write a functional Active Server Page that allows interaction between a database file and the Web, without getting caught in an SQL nightmare. She offers a snippet of SQL code and adds some logical layers, error checking and formatting.
[Read This Article]  [Top]
Mar 23, 2000 - Using an ADO Standalone/Custom Recordset in VBScript
Developer Stephan Onisick shows us how to create a standalone/custom recordset and use its organizational ability to perform logical tasks with data without connecting to a database. This article uses a small application written using VBScript, ADO 2.1, and an Excel spreadsheet to record and print computer expenses for tax preparations. The standalone recordset is saved in XML format, and the file can be updated with new data simply by reopening as a recordset and using normal recordset methods.
[Read This Article]  [Top]
Jun 8, 2000 - Get Your Data Faster with a Data Cache
Storing frequently used lookup data in a database is a great idea (e.g. order status codes, state names, etc.) that saves tremendous amounts of time in design and maintenance. However, retrieving that data from the database every time it is needed is very inefficient. This article describes how to use Application variables to cache frequently used lookup data in memory to achieve lightning fast access times. In my tests, I've seen as much as a 5000% increase in performance.
[Read This Article]  [Top]
Jun 21, 2000 - Keeping Track of Who's In Charge Today
Many offices, particularly in military and government organizations, are required to have someone in charge during office hours. If the official manager is absent, that person delegates responsibility to someone else as acting, but who?

A Key Personnel Today table shows who is acting in every official position and how to reach them.
[Read This Article]  [Top]

Related Books
Working with Active Server Pages
Teach yourself Active Web Database Programming in 21 Days
Related Knowledge Base Articles
INFO: ODBC Connection Pooling and ADO
Q166886 - 1997.06.23
Related Products
FileSystemObject
The FileSystemObject group is a set of COM objects that allow you to manipulate the file system on from an Active Server Page. FileSystemObject which is documented here is the version that comes with IIS 4.0. Which is much different then the limited version which shipped with IIS 3.0. The set of COM objects which consist of the FileSystemObject software are all free and cover almost every feature needed.
[Top]

Support the Active Server Industry



JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers