Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - best method of opening recordsets
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

best method of opening recordsets

 Post Reply Post Reply Page  12>
Author
the boss View Drop Down
Senior Member
Senior Member
Avatar

Joined: 19 January 2003
Location: Saudi Arabia
Status: Offline
Points: 1727
Post Options Post Options   Thanks (0) Thanks(0)   Quote the boss Quote  Post ReplyReply Direct Link To This Post Topic: best method of opening recordsets
    Posted: 29 June 2003 at 6:06am

whats is the most optimised way of opening recordsets in asp along with cursor and lock type option...respond with a code if u can..

Back to Top
Bunce View Drop Down
Senior Member
Senior Member
Avatar

Joined: 10 April 2002
Location: Australia
Status: Offline
Points: 846
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bunce Quote  Post ReplyReply Direct Link To This Post Posted: 29 June 2003 at 6:13pm
depends what you need it for
There have been many, many posts made throughout the world...
This was one of them.
Back to Top
the boss View Drop Down
Senior Member
Senior Member
Avatar

Joined: 19 January 2003
Location: Saudi Arabia
Status: Offline
Points: 1727
Post Options Post Options   Thanks (0) Thanks(0)   Quote the boss Quote  Post ReplyReply Direct Link To This Post Posted: 29 June 2003 at 7:50pm

well i need example for inserting, updating deleting and reading opreations... in simple word.. i need a code template..

Back to Top
Boecky View Drop Down
Groupie
Groupie
Avatar

Joined: 23 December 2002
Location: Belgium
Status: Offline
Points: 110
Post Options Post Options   Thanks (0) Thanks(0)   Quote Boecky Quote  Post ReplyReply Direct Link To This Post Posted: 30 June 2003 at 3:43am

I think this is the best way for reading:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>

'***Declare variables
Dim Conn
Dim rsTest
Dim ConnStr

'***Connectionstring
ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\test\testdb.mdb"

'***Make connection with the database
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open ConnStr

'***Make a recordset
Set rsTest = Server.CreateObject("ADODB.Recordset")
rsTest.CursorLocation=adUseServer 'Or use number 2
rsTest.CursorType=adOpenForwardOnly 'Or use number 0
rsTest.LockType=adLockReadOnly 'Or use number 1
rsTest.ActiveConnection = Conn
rsTest.Source = "Select * FROM table"
rsTest.Open
%>

...

<%
'***Close recordset and connection

rsTest.Close
Conn.Close
Set rsTest = Nothing
Set Conn = Nothing
%>

Back to Top
Gary View Drop Down
Senior Member
Senior Member
Avatar

Joined: 20 March 2002
Location: United Kingdom
Status: Offline
Points: 326
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gary Quote  Post ReplyReply Direct Link To This Post Posted: 30 June 2003 at 4:38am

Also, 0it is more efficient to wrap all the db related output within a response.write rather than opening and closing the asp tags....

More Efficient
Response.Write("<tr><td>" & rs("myColumn1") & "</td></tr>")
Response.Write("<tr><td>" & rs("myColumn2") & "</td></tr>")

Less Efficient
<tr><td><%=rs("myColumn1")%></td></tr>
<tr><td><%=rs("myColumn2")%></td></tr>

Having said that, personally I prefer to use the LESS effiecient method. Not sure why - possibly old habit (before I learnt the difference in performance), readability of the code, or the pain of dealing with multiple single/double quotes.

Back to Top
Boecky View Drop Down
Groupie
Groupie
Avatar

Joined: 23 December 2002
Location: Belgium
Status: Offline
Points: 110
Post Options Post Options   Thanks (0) Thanks(0)   Quote Boecky Quote  Post ReplyReply Direct Link To This Post Posted: 30 June 2003 at 4:51am
And does anyone also know the CursorLocation, CursorType, LockType for insert, update and delete? Coz I also was looking around for these question Tkx
Back to Top
the boss View Drop Down
Senior Member
Senior Member
Avatar

Joined: 19 January 2003
Location: Saudi Arabia
Status: Offline
Points: 1727
Post Options Post Options   Thanks (0) Thanks(0)   Quote the boss Quote  Post ReplyReply Direct Link To This Post Posted: 30 June 2003 at 5:20am
Originally posted by Boecky Boecky wrote:

I think this is the best way for reading:

this is very similar to the recordsets generated by dreamweaver MX.. well all i do mostly is to make record set using dreamweaver and then copy paste it.. since i dont develop any application for live enviroment use.. most of them r just play around and for easing to explain my idea to others !!

Back to Top
Bunce View Drop Down
Senior Member
Senior Member
Avatar

Joined: 10 April 2002
Location: Australia
Status: Offline
Points: 846
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bunce Quote  Post ReplyReply Direct Link To This Post Posted: 30 June 2003 at 5:25am

Actually, the most efficient way of reading a recordset would be to transfer it to an array using getrows() or getstring(), or use a disconnected recordset.

Also the differences in ASP3 between using HTML within Response.write or on its own are negligible, so use what is best for you (and others) to program, understand and troubleshoot.

For those moving to .Net, and in fact many other languages, it would be advisable to try and separate your presentation code from your logic code as much as possible.

Cheers,
Andrew



Edited by Bunce
There have been many, many posts made throughout the world...
This was one of them.
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.