Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Basic questions about the RecordSet object 2

Status
Not open for further replies.

ChampionX

Technical User
May 24, 2001
5
ES
Hi it's me again. I have some more questions. I feel like a parasite for just making questions, I'd like to help other people too but, by now, my knowledge is very scarce :(

Well, my questions (mainly regarding the recordsets):

1) Is it different to "build" a recordset object like this:

Code:
   set rs = conn.Execute(SQL)

or like this:

Code:
   set rs = Server.CreateObject ("ADODB.Recordset")
   rs.Open SQL, Connection
Are they the same?

2) Can I "fill" the same RecordSet object more than once in the same page for 2 different tasks? For example:
Code:
SQL="Select * from table1"
set rs = conn.Execute(SQL)
...(data processing)...
Code:
SQL="Select fieldone, fieldtwo from table2"
set rs = conn.Execute(SQL)
...(data processing)...

It seems it works but I don't know if, eventually, I might get corrupted data for "setting" it 2 times...

3) How much important is to do a rs.close and conn.close (to close a recordset and connection object) at the end of the document (or when I'm done with them). What could happen if I do not explicitly close them?

4) This one is not about recordsets. I have written some kind of "mini" search function (I use asp with VBscript). It works, but I have had to do something like this to compare every set of text strings:

Code:
if LCase(string1)=LCase(rs.fields("field_one")) then ...

, because I realised the comparison was case sensitive, so I have "standardized" the case to lower when comparing. Is this just a "dirty workaround" for it, or it is an acceptable tecnique?

Thanks for any answers to my questions :)

ChampionX
 
1. The Excecute method may be used to execute a SQL command against a data source, much like a Command object. The recordset that is returned by the Excecute method is always read-only, with a forward-only cursor. If you need other feature settings, you first need to create, configure, and open a Recordset object to execute the command.

 
1) not 100% sure I agree that you can't specify the cursor type and lock options using conn.execute(sql); I think you can, but I can't locate my code right now :(

2) It's perfectly fine to reuse your rs object. No problem.

3) It's always recommended to close and set to nothing when done. If not, resources are tied up that don't need to be.

4) I don't know of a better way; that's what I do (except I usually use UCase).

P.S. Don't worry about asking questions. For me, it's only the folks who want you to do everything for them or who require you to be a mind reader in order to divine what they are asking that bug me.

Keep on truckin'! (a slogan from the 70's)
 
Thanks Puitar, and thanks specially to Glenn: your answer was detailed and thorough! And yes, I also hate when people asks something (not in asp, but in general, whatever) in a vague and ambiguous way!

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top