Efficient way to Get an ADO RecordSet

Contributed by
Rating: 3 stars3 stars3 stars3 stars3 stars / 2
October 31, 1999
Rate this Article:
MEH MEH++


SEARCH ASP FREE
TOOLS YOU CAN USE

advertisement

It is good pratice on Web Sites to use Dis-connected RecordSets. This is because on high traffic sites the number of connections permitted can be exceeded very quickly.
In addition resources are taken up with each connection.
In this Example you have a DIS-CONNECTED RecordSet. You can then Add, Update, Delete or do whatever you please because the RecordSet is not Closed, it just does not have a connection. When you want to update the Database you merely restore the connection.
Enough waffle here is how you do it.

Dim RS, SQL, MyDSN
MyDSN = "Provider=SQLOLEDB; Data Source=[]local; Initial Catalog=DB; User Id=sa;"
SQL = "SELECT * FROM SomeTable"
Set RS = Server.CreateObject("ADODB.RecordSet")
With GetRS
    .CursorLocation = adUseClient
    .CursorType = adOpenStatic
    .LockType = adLockOptimistic
    .Open SQL, MyDSN
    Set .ActiveConnection = Nothing
End With
...
...Do your Stuff
...
Set RS.ActiveConnection = MyDSN
RS.Update
Set RS = Nothing

PS. I always use Client Side Cursors because you can readily achieve the RecordCount.

blog comments powered by Disqus
DATABASE CODE ARTICLES

- Deployment of the MobiLink Synchronization M...
- MobiLink Synchronization Wizard in SQL Anywh...
- Finding Matching Records in Data Access Pages
- Using the AccessDataSource Control in VS 2005
- A Closer Look at ADO.NET: The Command Object
- A Closer Look at ADO.NET: The Connection Obj...
- Using ADO to Communicate with the Database, ...
- Code Snippets: Counting Records
- Constraints In Microsoft SQL Server 2000
- Multilingual entries into a DB and to be dis...
- Two combos, one textbox example
- ADO Recordset Paging
- SQL Server Database Creator - .NET Version
- Getting A List of Tables From SQL Server
- Discussion & Listserv Module by Mike Eck...

ASP Web Hosting ASP.Net Web Hosting Windows Web Hosting
 
 
 

ASP Free Forums 
 RSS  Tutorials RSS
 RSS  Forums RSS
 RSS  All Feeds
Site Map 
Request Media Kit
Write For Us Get Paid 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Privacy Policy 
Support 


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 3 - Follow our Sitemap
Most Popular Topics
All ASP.Net Tutorials