Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Newbie Question: Data store access
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

seahorse
Senior Member

USA
1075 Posts

Posted - 01 March 2002 :  04:21:11  Show Profile  Visit seahorse's Homepage
Hi Everybody,

I've been studying ASP from books and by looking at open source code available on the net. One of the things I've discovered is that some of the open source code I've been looking at doesn't look much like what my ASP book has in it. For Example, My Wrox Beginning ASP 3 book has something like this in it for data store access.

<%
Dim objConn, objRS
Dim adOpenForwardOnly, adLockReadOnly, adCmdTable
adOpenForwardOnly=0
adLockReadOnly=1
adCmdTable=2

Set objConn=Server.CreateObject("ADODB.Connection")
Set objRS=Server.CreateObject("ADODB.RecordSet")

objConn.Open strConnect
objRS.Open "Movies", objConn, adOpenForwardOnly, adLockReadOnly, adCmdTable

(more code, yada yada yada...)
%>


However, I've seen open source code with something like this:

<%
Dim objConn, objRS, strConnect, strSQL

strConnect = "connection yada yada yada; Persist Security Info=false"
strSQL="SELECT * FROM tblTABLE ORDER BY table_id"

Set objConn=Server.CreateObject("ADODB.Connection")
objConn.Open strConnect
Set objRS=objConn.Execute (strSQL)

(more code, yada yada yada...)

%>


I'm much more comfortable with the second example. Is there any value in doing things like the first example from my ASP book? Do people actually code like that or is it something you only see in a textbook? I'd appreciate any opinions you could provide.

Thanks,
Ken

===============
The greatest tragedy is a child without a loving parent.

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 01 March 2002 :  06:52:15  Show Profile  Send ruirib a Yahoo! Message
quote:

Hi Everybody,


However, I've seen open source code with something like this:

<%
Dim objConn, objRS, strConnect, strSQL

strConnect = "connection yada yada yada; Persist Security Info=false"
strSQL="SELECT * FROM tblTABLE ORDER BY table_id"

Set objConn=Server.CreateObject("ADODB.Connection")
objConn.Open strConnect
Set objRS=objConn.Execute (strSQL)

(more code, yada yada yada...)

%>





This second option is less flexible than the first one, because it will only return a forward only, read only recordset. If you need a recordset with different characteristics (moving back and forth in the recordset, updating records, etc.) you'll need to use the first method. That's the main difference.
So the first option is a more generic one, that you can use in every situation. The second one you can only use when a forward only, read only recordset is all you need.

Hope this helps...



-------------------------------------------------
Installation Guide | Do's and Dont's | MODs
Go to Top of Page

seahorse
Senior Member

USA
1075 Posts

Posted - 03 March 2002 :  23:26:33  Show Profile  Visit seahorse's Homepage
quote:

quote:

Hi Everybody,


However, I've seen open source code with something like this:

<%
Dim objConn, objRS, strConnect, strSQL

strConnect = "connection yada yada yada; Persist Security Info=false"
strSQL="SELECT * FROM tblTABLE ORDER BY table_id"

Set objConn=Server.CreateObject("ADODB.Connection")
objConn.Open strConnect
Set objRS=objConn.Execute (strSQL)

(more code, yada yada yada...)

%>





This second option is less flexible than the first one, because it will only return a forward only, read only recordset. If you need a recordset with different characteristics (moving back and forth in the recordset, updating records, etc.) you'll need to use the first method. That's the main difference.
So the first option is a more generic one, that you can use in every situation. The second one you can only use when a forward only, read only recordset is all you need.

Hope this helps...



-------------------------------------------------
Installation Guide | Do's and Dont's | MODs




Thanks! There's no one to tell you this stuff when you're studying on your own.

Ken

===============
The greatest tragedy is a child without a loving parent.
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 04 March 2002 :  05:49:22  Show Profile  Send ruirib a Yahoo! Message
quote:

Thanks!


You are welcome .
quote:

There's no one to tell you this stuff when you're studying on your own.


Well, it really depends on the "company" you choose for your study. I'm using Wrox's Professional Active Server Pages 3.0. That was where I saw written for the first time, as this was the book that I used as my source for learning ASP.



-------------------------------------------------
Installation Guide | Do's and Dont's | MODs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.38 seconds. Powered By: Snitz Forums 2000 Version 3.4.07