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 May 19th, 2004, 02:18 AM
Authorized User
 
Join Date: May 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default CursorTypeEnum & LockTypeEnum Question

Someone that can tell me a little about how and when to use a CursorTypeEnum & LockTypeEnum.

'---- CursorTypeEnum Values ----
Const adOpenForwardOnly = 0
Const adOpenKeyset = 1
Const adOpenDynamic = 2
Const adOpenStatic = 3
'---- LockTypeEnum Values ----
Const adLockReadOnly = 1
Const adLockPessimistic = 2
Const adLockOptimistic = 3
Const adLockBatchOptimistic = 4

I know that if i want to read from a database i use ,0 ,1 or ,adOpenForwardOnly ,adLockReadOnly

but what about if i add a new record or will edit a record.
and what can i use adLockBatchOptimistic and so on till !?

 
Old May 19th, 2004, 02:25 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Take a look at this FAQ: http://www.adopenstatic.com/faq/jetcursortypes.asp

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old May 19th, 2004, 04:05 AM
Authorized User
 
Join Date: May 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi.

and Thanks, but Have I understand this right that i JUST have to use.

To read the database
adOpenForwardOnly ,adLockReadOnly

To delete or edit in the database
adOpenKeyset, adLockOptimistic

To add a new on in the database
Hmm yes what shut I use here !??

but do i have understand it about read/delete/edit !??


 
Old May 19th, 2004, 04:10 AM
Authorized User
 
Join Date: May 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

One question

CursorLocation !?? Should I use that as well as CursorType and LockType !? or is it ok just to use Cursor and Lock Type !?

and what do CursorLocation do !??

 
Old May 19th, 2004, 04:43 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Well, it depends.

If indeed all you're doing is read records, adOpenForwardOnly, adLockReadOnly is the best way to go. This creates a "firehose" cursor which is optimized to read results in a readonly, forward only manner. This means you must read the records in sequential order, one by one. So, once you have read record 2, you can't go back to record 1.

To add new records, you must use an updateable cursor as well. adOpenKeyset would work fine as it allows records to be added to the recordset.

Cursor location determines the place where the cursor lives. With a Server Side cursor, the "server" (that is, the database engine) takes care of scrolling. So, if you call MoveNext() 100 times to retrieve record 101, all you send over the wire is record 101.
With a client side cursor, scrolling takes place at the client. This means that *all* records are send to the client, even if you're not using them. If you call MoveNext() 100 times, you actually transfer 101 records from the "server" to the "client".

In ASP scenarios, I prefer direct SQL over the AddNew, Update etc methods of the recordset. Using these methods causes quite some overhead. Using the Execute method of the Connection object will perform better, and is, IMHO, easier to use:

Dim SQL
SQL = "INSERT INTO Client (Name, Address) VALUES('CustomerName', 'CustomerAddress')
MyConnection.Execute(SQL)

No need to figure out what cursor type you need to set, as you don't need them at all.

Check out the ADO guides for more information:
http://msdn.microsoft.com/library/de...ireference.asp
http://msdn.microsoft.com/library/de...ortypeenum.asp
http://msdn.microsoft.com/library/de...cationenum.asp

HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Mildred Pierce by Sonic Youth (Track 8 from the album: Goo)





Similar Threads
Thread Thread Starter Forum Replies Last Post
RadioButtonList & SQL question rdove84 ASP.NET 1.0 and 1.1 Basics 2 November 8th, 2006 01:55 PM
Linux & KDE & C++ & QT & MYSQL & Kdevelop Munnnki Linux 0 January 2nd, 2005 05:41 PM
A question for Englere & buzzterrier swandown BOOK: ASP.NET Website Programming Problem-Design-Solution 3 October 29th, 2004 10:00 AM
Packaging & Deploying - Basic question alymoiyed VB How-To 0 June 30th, 2004 02:42 AM
Tables & Queries question Kenny Alligood Access 2 July 14th, 2003 11:14 AM





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