RecordSets w/o a Connection object?

Results 1 to 2 of 2

Thread: RecordSets w/o a Connection object?

  1. #1
    Andrew Sinning Guest

    Default RecordSets w/o a Connection object?

    Looking through some examples from a class I took a while back, it seems that it is possible to open an RS on a db w/o first creating a connection to the db. Here&#039;s an example:<BR><BR>rs = CreateObject("ADODB.Recordset")<BR>db = "UID=;,PWD=;DSN=asp1Db1"<BR>strSQL = "SELECT * FROM users"<BR>rs.Open strSQL, db, 1, 2<BR>rs.AddNew <BR>...<BR><BR>Is this okay? When, if ever, is a Connection required? What are the performance pros and cons of not first making a connection object?<BR><BR>Thanks<BR>

  2. #2
    Join Date
    Dec 1969

    Default Not's just hidden...

    In truth, anytime you make a SQL query with a RecordSet, you *must* be using a Connection object and a Command object in addition to the RecordSet object. But the "trick" is that the other objects might be "hidden" from you--created temporarily and living just long enough to do their jobs.<BR><BR>If you will only open one RecordSet on the ASP page, then this is fine: You would have only used the Connection (and Command) object for that short period of time anyway.<BR><BR>If, however, you have more than one RecordSet (or open the same one multiple times), then doing without the Connection object is a bad idea: The creation and destruction of a Connection is an expensive process, so you want to do it only once per page, if possible. (The Command object is a pretty lightweight thing, in contrast, so no big deal if you create one of them for each recordset.)<BR><BR>Hokay?<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts